finished-major-functionality-starting-UX-polish

I'm having a hard time reviewing this code, since I don't know what it does. Could you add high-level comments explaining the code? 

In most cases, constructing HTML by hand like this isn't great, but it's hard to give an alternative without that.