Minor refactorings, added Logger.