thread safety fixes and CRef rename
gh-52 gh-29