Modifications: Shorten z, sort substitutions in v and w