Fix sync problem when changing tabs