Improved the way the changes are tracked in the stateListener