Code refactoring, added Datalogger functionality