Replace the periodic_copy module with a new, simpler, lattice iterator.
I also took the opportunity to get rid of a few MAX_DIM.