Added boilerplate for failed promises.
Refactor main scope code.
Add spinner.