segmentation fault caused by free'ing battles twice