Discuss the functions of the battery management system