Some work on refactoring Entity.cs

Also stress tested it, just as fast as before.