[Neil, Chris] Refactor if expressions and remove unused variables.