a bit more cleanup and restructuring