Cleanup and document some framework-code in popup.js