changed the createMap function to flatten all layers of images into one. Should help performance a little.