huge refactoring: methods moved to classes, major logging improve

May be use a constant?