Minor, largely cosmetic improvements

Rename some variables to be more clear about their purpose
Make some conditions simpler
Remove some whitespace

@pbadenski
@robyoung