Miscellaneous code cleanup