more bugfixes with locks. fixed infinite loops due to broken connections