Edited to accurately follow threading paradigm.