Moved logging settings into separate module
Added logging option --log-level

And a bit of refactoring.
Removed duplicate debug output