Added pro0per handling of mode argument