minor code fixes and cleanup