Fix crash on tab change