app.js, popup.js - code reformatted, some refactoring. This commit needs code review