refractor and reorganize DemandSpike code to work better with the webui