Miscellaneous general purpose functions