robust implementation of getLattice* functions