refactored code to clean it up
cleanup time functions a bit
cleanup code a bit
cleanup code a bit
fixed haddock comments