improve detection of state changes performed in callbacks; general cleanup; calling state($state) with the current state now invokes the callback methods anyway