Handling phrases by escaping and restoring quotes