full port of FMapSubst.