Restructuring gateway and webservice