(cleanup) Clean-up client-side code. Add comments.

@blankmaker 

Needs more work, but did a little spring cleaning.