Improved mode handling