wip: more thread safety