Fix many code style issues

A lot of bad style things crept in over the years making the code
squashed and non-uniformed.

This fixes a number of issues highlighted by Rubocop.