Reworked some time functions