minor bug fix and some commenting