Add support for promises. Closes #16