Refactoring to reduce complexity

Hey all-

This doesn't change any functionality whatsoever, but reduces the cyclomatic complexity and makes it a little easier to read.

Cheers!