Added threading. Only first stage of this, not sure how well this works.