Further modifications on lattice code - needs much more work