Minor reformatting and whitespace changes
Decreased nesting; early return
Whitespace changes and a new comment
Used `elseif` where suitable
Decreased nesting
Minor reformatting
Return early
Reformatted
Simplify
Reformatted
Return early
Decreased nesting
Reformatted
Return early
Reformatted
Restructured `switch` statement
Replaced `switch` with if-else
DRY
Avoid tiny else branches
Used `elseif` where suitable