Fixed entity deletion bug (hopefully)