Import query.
Final py3k fixes.