Improved time handling