Task queuing

Implemented task queueing so we don't have to wait for db object in callback function.