Fix lots of nits; whitespace, global vars, formatting

Test plan: do a few problems of each type locally

Auditors: alpert