fixed stuff, added map_free to free map's memory