added the query reindex smoke test.
fixed a lot of related bugs.