Refactored util.
Refactor lattice.