Fixing some bugs related to time.