Started webservice code rebuild

Including some refactoring