Please add some in line comments here to improve clarity. This block is executed only for the first element of each partition and it initializes the variables. It would help to explain this and also the logic of initialization.