Replace when with bluebird.

Closes #968