bugfixes in lattice.cc