Miscellaneous fixes and clean up