fixed errors on entity destruction