trying to fix stuff and just making it more broken
fix problem in the lattice logic.  will do performance improvements later
performance improvements to the lattice (creating all possible combinations) logic