Added escaping to query assembly.