Removed unused debugging code
Fixed some deadlocking issues