zk python refactoring