added getStateChangeMillis and a few other tweaks