Rework Endmorphic without replacing the existing Endo

Thanks to Stephen Compall who submitted patches to the original branch.