Fixed threading

Fixed threading hopefully for good!