bug fixes and comment style improvements