Bug fixes and investigating more efficient use of queries