Replace methodology for removing double whitespace

Fixes issue #1480
Merge pull request #1542 from jrfnl/Fix-1480-var-replacement-spaces

Replace methodology for removing double whitespace