parameter encoding fix and minor refactoring
Merge remote-tracking branch 'origin/master'