Refactors to use promises

The call back hell was unmaintainable. Moved to promises to make sense
of the workflow.