Refactored some code. Added the beginnings of the code to determine if all threads are exhausted and thus contest completed