Don't compare booleans for equality to TRUE and FALSE
TRUE is 1, but every other non-zero value is also considered true. Comparing for equality with TRUE would only consider 1 but not the others. Also normalize booleans in a few places.
Showing with 42 additions and 39 deletions