Fixing bug that caused replace last to trim the end of the string.