Misc code cleanup