Lattice snapping

This should only really include lattice.py, so hopefully everything will still work...