fix submap saving, erase memory leaks, ignore incomplete submaps