Misc cleanup and fix entity death bug