Rewrite some of pull request #46 to use 'Q' promises library and try to make sure we are handling asynchronous control-flow correctly.