Some code cleanup and commenting.
moved time functions to their own class.