Potential fix for the string_escape bug, by implementing my own escape function.