Move pointer outside of statechange condition
Rename object->entity where applicable to avoid term ambiguity