Code cleanup and minor style improvements

See: https://github.com/bbatsov/ruby-style-guide