Added time tracking and storing states