Remove some rather ugly explicit case statements