Fixed Syntax error: changed $node to $entity in hook_entity_delete and hook_entity_update.