huge refactoring: methods moved to classes, major logging improve

What's this?