indentation changes and fixing memory leaks in getbattery function