Merged bitbucket.org/shlomif/libtap/src, fixed locking