Bugfixes on substituting expressions.