fix calculation of Z for rotates and shifts