Fixed topology generation, added periodicity to the new code, and misc changes.