Miscellaneous code for various purposes