adding some logging, and straightening up some general stuff