Added XYZ order and some fixing