Refactored path variable substitution - fixes #78