Tidying up the locking and hiding of threads as well as removing some unneeded files