Attempt to fix memory leaks,clean up layerMap