fix batterIndex bugs and upgrade libraries