Refactoring

Removed nested conditionals in favor of guard clauses. Minor white-space and `switch` curly brace formatting.