A lot of restructuring to better take use of mutexes in the threaded functions. Commiting before doing even more changes.