Moved escaping to output for easier auditing.