Added energy APIs and fixed some lines of code...