Miscellaneous useful auxiliary functions: