Refactors async tasks into database interface and separate task classes.