Misc cleanup and fixing