Comments and small refactoring

Mostly explain what the code is doing, and also rename buttonContol to
the more appropriate buttonControl.