draft of everything except energy.c