Added protection from null queries.