Switched logging and begin refactoring