Cleaned up the time code to only use four variables for easier understanding.