1. Fix bug: query incorrect.
2. Tidy queries.