Added file logging, code refactored