Ref #126 Fixed threading errors.