deadlock solving. Not finished.