Sanitize queries and actually deal with prefixes