Add function to free resources used by the map