Fix error while detecting board. Fix error free memory