Refactored the code, and added UTC timestamps to the logged data (untested)