Updated code to work right with battery meter / Code cleanup -- TESTED WORKING