Update to use promises

So far, this branch adds support for promises, though while it's being r?'d I might do some more tweaking and tidying :-)