More database indexing process restructuring

Make better use of asynchronous calls to avoid sending queries to the
database before previous queries are processed.