This looks like a backwards-incompatible change. Also, why do you make z and p into arrays and not k?