Miscellaneous utility code