Fixed bug in StateMonitorThread