fix 'flip' logic to take into account rotation_alignment and keep_upright (#470)