Refactor z.py.