Refactor!

Indentation was starting to get too deep, so I did some refactoring and
renaming.