Program now sends events when changing state and NodeWait has been fixed