Bug fixes in time calculations