Crash fix with switch statements