Adding a bunch of debuggin and locking to see if we can fix the race condition.