Issue101

Some performance optimizations as well as making the resetMap() function more robust.