Energy and thermal management