Make handling of the mode argument more correct