Client refactoring
Fixed bug in variable substitution