I feel like this would be easier to read if sections in if blocks were indented. If this totally diverges from style in the rest of the project then ignore me I guess, but at a glance it's hard to suss out which things are controlled by which if block.