more logging + minor fixes
refactoring + minor changes