Added time-stamp to logs and cleaned up the code a bit