Not an error, just a style observation: it took me a few seconds to wonder "why the hell would the mode ever be negative" until I realized you meant to say it should always be positive :), in which case the equivalent condition 'mode >=0' is much easier to understand at first glance. Same goes for 'mode < 4' -> 'mode <= 3'.