added focus event handler to fix tab switch bug by forcing a sync; fixed server/client out-of-sync issue