fix double 'var' declaration, add some comments about synchronization