More robust username fetching, refactoring, and comments

I swear I don't know how the jQuery code vanished from what I touched.