Cleanup, rewrite main.js for extensibility.

Minor improvements to sidebar