fixed some bugs, too many locks ...