some more cleanup, more logging, and a wee bit of refactoring