Migrate changes from remove-entity-typeloader

Migrate changes required to remove the entity typeloader. This was
achieved using git diff to generate patch files to be applied through
IJ.
Fix ClassCastException