Code overhaul to use promises

Turns out PRing from one's own repo is useful!