fix #708 and redo how metamodel refs are typechecked