Fix crash on traditional and flipped layouts