Because we are just preparing beta array for the next iteration - we have set everything to the current nCP, and now, we are solving QP for the new cutting plane. That's why we add zero to the beta array and increase the nCP by one. 
The beta array is then recalculated in QP call and  I, H, H_diag is resolved later with the help of newly computed beta.

The original code was correct, I have checked it to our original MATLAB code obtaining the same results. However, I agree that the boundary cases for BuffSize were potential risk.