comments and refactoring / reorganization that came up during code review