Added support for state-changing callbacks.