Added onActivate and onDeactivate functions