Refined bit un needed code and switch implementation for mode.