Leaf refactor