Miscellaneous helpful functions, classes and decorators.