Moved normalization of the transformation matrix to the py code