Fix handling of escape sequences