minor bug fixes and cleanups