fix up comments, and a little refactoring