added comments and fixed a few minor oversights from initial reorganization