Shouldn't the offset be ``4 + i`` at this point instead of zero?  This will currently overwrite a portion of the max_buffer section.