fixed problem in subst, minor cleanup