cleanup and lock type bugfix