Added popup.js since popup.html can't contain inline js.
Added configuration to popup.html.
Several bug fixes.