Bug fixes for switch