Feature lattice2

I have addressed the issues. Can you all take another look.Thanks.
Yes, I am referring to all the `#end if` and similar `#` comments in the PR