minor bug fixes and cleanup