Code refactoring
Refactored code a bit - all stdout moved to debug() calls, that is configurable now