Lots of entity fixes and improvements