Fix a bug with mode handling