bugfixes to time functions