fixed deactivation / reactivation bug, cleaned up related code