Fixes for switch statements, stack overflows