Rewritten time module to a more functional look.