Adding proper logger and some very minor refactoring.