Refactor to use Q.js promises internally.