fixed segfault, sped up generation and maps