incorporate Mode fix from Joel (issue #2615)