small bug fix and cleanup