Fixed bugs in the entity system and the render batch