Misc fixes and cleanup.