Minor bug fixes and cleanups.