@fiveoutofnine.eth
The idea is to reduce as many zero slot writes as possible because writing to zero slots costs 20k gas, whereas writing to nonzero slots only costs 5k gas.
It might look a little complicated, but if you break it down, it's not too bad: