Fix NPE when EntityDynamicType constructor calling entity.toString

And some other very minor fixes.