Misc fixes and cleanups