Miscellaneous fixes and cleanup