Fixed: typo
Fixed: equality operators
Formatting: Make if statement more readable

The if statement had a lot of sub-clauses. These were factored out into variable assignments.