Seems like most of these `i` values can just be inlined since they are single use