Fix reorient code to work in all cases