Fixed escaping whitespace and striping trailing spaces and lines in input and tracebacks.