Cleaned up the copyMapWithLayers function.

Wish I could claim credit for it, but the copyMap function that's already in the
original code does the same thing. However, can't use their copyMap function as
a replacement. The game will segfault if you do.