Update when switch.
Some bugfixes.