Don't crash on ZooKeeper's death.

Currently, if ZooKeeper dies, the whole stack crashes - as a deleted callback is executed. This patch fixes it - and also refactors the ZooKeeper callback implementation (as old one was so complicated, that I was unable to find the bug without simplifying it).