Migrate most database operations to async.
Refactor async tasks.