some refactoring and fixes for zookeeper usage