Misc fixes and cleanup