Improved promise-code.

I removed some layers of nesting for the promise-code, hopefully
increasing readability!
Merge pull request #4 from jwoudenberg/master

Improved promise-code.