minor reorganization, major additions for parallel querying support and rewriting