fix race condition in vars creation vs Register.
switch to a more strict register scheme
Merge branch 'stats-fix'