Master thread written, with supporting classes/functions.

Conflicts: