logging, refactoring, cleanup