Handle variable substitutions with .realmath better