Misc cleanup and fixes