added api for switching states
added a statemachine
integrated time_is_updated flag