Water, energy and resource activities in the water and wastewater treatment process are integrated in order to recover nitrogen, phosphorous, biopolymers and/or elements to produce biofuels and other valuable materials from wastewater and enhance energy 11 of 21 recovery. Other objectives are the application of water saving techniques avoiding product losses and the elimination of micro pollutants and drug resistant bacteria.