Improve time handling