Treatment of N substances and phosphates