minor bug fix and cleanup