Fix bug with deactivation.

The fix in #689 has a bug where deactivation code is never run. This PR fixes this. Sorry guys.