Added the spaceReplace method to maintain whitespace structure.