Funy thing happend. I found a piece in the code for making underground connections that in some cases disconnected pipes and immediatelly connected back again. I fixed it, thinking that it is just inefficient. But turns out it fixed this bug. Work well done.