various entity bug fixes

* fix random crash on checkEnterLeaveEntities
* clear all octree related state when disconnecting from a domain
* fix crash in mouse messages while quitting