Some work on energy api. Other changes too.