Add query type to search for nicknames.

Also, slightly clean up the messy parsing code.