a bit more cleanup and comments