Major improvement to use of promises, logging and reference to global variable myApp