Refactored lattice.py and fluid.py