diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java b/src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java
index 4b887e4..f63ead8 100644
--- a/src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java
+++ b/src/main/java/org/onap/clamp/clds/util/drawing/ImageBuilder.java
@@ -78,8 +78,8 @@
     }
 
     ImageBuilder circle(String dataElementId, int lineThickness) {
-        Shape circleStart = new Ellipse2D.Double(currentPoint.x, currentPoint.y - CIRCLE_RADIUS, 2 * CIRCLE_RADIUS,
-                2 * CIRCLE_RADIUS);
+        Shape circleStart = new Ellipse2D.Double(currentPoint.x, ((double) currentPoint.y) - CIRCLE_RADIUS,
+                2.0 * CIRCLE_RADIUS, 2.0 * CIRCLE_RADIUS);
 
         Stroke oldStroke = g2d.getStroke();
         g2d.setStroke(new BasicStroke(lineThickness));
diff --git a/src/main/java/org/onap/clamp/configuration/ClampGsonDataFormat.java b/src/main/java/org/onap/clamp/configuration/ClampGsonDataFormat.java
index c4d28be..ca5f376 100644
--- a/src/main/java/org/onap/clamp/configuration/ClampGsonDataFormat.java
+++ b/src/main/java/org/onap/clamp/configuration/ClampGsonDataFormat.java
@@ -53,8 +53,7 @@
     /**
      * Use the default Gson {@link Gson} and with a custom unmarshal type.
      *
-     * @param unmarshalType
-     *        the custom unmarshal type
+     * @param unmarshalType the custom unmarshal type
      */
     public ClampGsonDataFormat(Class<?> unmarshalType) {
         this(null, unmarshalType);
@@ -63,10 +62,8 @@
     /**
      * Use a custom Gson mapper and and unmarshal type.
      *
-     * @param gson
-     *        the custom mapper
-     * @param unmarshalType
-     *        the custom unmarshal type
+     * @param gson          the custom mapper
+     * @param unmarshalType the custom unmarshal type
      */
     public ClampGsonDataFormat(Gson gson, Class<?> unmarshalType) {
         this.gson = gson;
@@ -76,8 +73,7 @@
     /**
      * Use the default Gson {@link Gson} and with a custom unmarshal generic type.
      *
-     * @param unmarshalGenericType
-     *        the custom unmarshal generic type
+     * @param unmarshalGenericType the custom unmarshal generic type
      */
     public ClampGsonDataFormat(Type unmarshalGenericType) {
         this(null, unmarshalGenericType);
@@ -86,10 +82,8 @@
     /**
      * Use a custom Gson mapper and and unmarshal token type.
      *
-     * @param gson
-     *        the custom mapper
-     * @param unmarshalGenericType
-     *        the custom unmarshal generic type
+     * @param gson                 the custom mapper
+     * @param unmarshalGenericType the custom unmarshal generic type
      */
     public ClampGsonDataFormat(Gson gson, Type unmarshalGenericType) {
         this.gson = gson;
@@ -104,7 +98,7 @@
     @Override
     public void marshal(final Exchange exchange, final Object graph, final OutputStream stream) throws Exception {
         try (final OutputStreamWriter osw = new OutputStreamWriter(stream, StandardCharsets.UTF_8);
-            final BufferedWriter writer = IOHelper.buffered(osw)) {
+                final BufferedWriter writer = IOHelper.buffered(osw)) {
             gson.toJson(graph, writer);
         }
 
@@ -120,7 +114,7 @@
     @Override
     public Object unmarshal(final Exchange exchange, final InputStream stream) throws Exception {
         try (final InputStreamReader isr = new InputStreamReader(stream, StandardCharsets.UTF_8);
-            final BufferedReader reader = IOHelper.buffered(isr)) {
+                final BufferedReader reader = IOHelper.buffered(isr)) {
             if (unmarshalGenericType == null) {
                 return gson.fromJson(reader, unmarshalType);
             } else {
@@ -153,7 +147,7 @@
     }
 
     public Type getUnmarshalGenericType() {
-        return this.unmarshalType;
+        return this.unmarshalGenericType;
     }
 
     public void setUnmarshalGenericType(Type unmarshalGenericType) {
diff --git a/src/main/java/org/onap/clamp/loop/CsarInstaller.java b/src/main/java/org/onap/clamp/loop/CsarInstaller.java
index 16351b8..38a6f93 100644
--- a/src/main/java/org/onap/clamp/loop/CsarInstaller.java
+++ b/src/main/java/org/onap/clamp/loop/CsarInstaller.java
@@ -42,27 +42,18 @@
 import org.onap.clamp.clds.sdc.controller.installer.ChainGenerator;
 import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
 import org.onap.clamp.clds.sdc.controller.installer.MicroService;
-import org.onap.clamp.clds.util.JsonUtils;
 import org.onap.clamp.clds.util.drawing.SvgFacade;
 import org.onap.clamp.loop.deploy.DcaeDeployParameters;
+import org.onap.clamp.loop.service.CsarServiceInstaller;
 import org.onap.clamp.loop.service.Service;
-import org.onap.clamp.loop.service.ServiceRepository;
 import org.onap.clamp.policy.Policy;
 import org.onap.clamp.policy.microservice.MicroServicePolicy;
 import org.onap.clamp.policy.operational.OperationalPolicy;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
-import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
-import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
-import org.onap.sdc.tosca.parser.enums.SdcTypes;
-import org.onap.sdc.toscaparser.api.NodeTemplate;
-import org.onap.sdc.toscaparser.api.Property;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
-import org.yaml.snakeyaml.Yaml;
 
 /**
  * This class will be instantiated by spring config, and used by Sdc Controller.
@@ -83,9 +74,6 @@
     LoopsRepository loopRepository;
 
     @Autowired
-    ServiceRepository serviceRepository;
-
-    @Autowired
     BlueprintParser blueprintParser;
 
     @Autowired
@@ -97,19 +85,18 @@
     @Autowired
     private SvgFacade svgFacade;
 
+    @Autowired
+    CsarServiceInstaller csarServiceInstaller;
+
     /**
-    * Verify whether Csar is deployed.
-    * 
-    * @param csar The Csar Handler
-    * @return The flag indicating whether Csar is deployed
-    * @throws SdcArtifactInstallerException The SdcArtifactInstallerException
-    */
+     * Verify whether Csar is deployed.
+     * 
+     * @param csar The Csar Handler
+     * @return The flag indicating whether Csar is deployed
+     * @throws SdcArtifactInstallerException The SdcArtifactInstallerException
+     */
     public boolean isCsarAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException {
-        boolean alreadyInstalled = true;
-        JsonObject serviceDetails = JsonUtils.GSON.fromJson(
-                JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class);
-        alreadyInstalled = alreadyInstalled
-                && serviceRepository.existsById(serviceDetails.get("UUID").getAsString());
+        boolean alreadyInstalled = csarServiceInstaller.isServiceAlreadyDeployed(csar);
 
         for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
             alreadyInstalled = alreadyInstalled
@@ -118,7 +105,6 @@
                             blueprint.getValue().getResourceAttached().getResourceInstanceName(),
                             blueprint.getValue().getBlueprintArtifactName()));
         }
-        
         return alreadyInstalled;
     }
 
@@ -127,24 +113,24 @@
      * 
      * @param csar The Csar Handler
      * @throws SdcArtifactInstallerException The SdcArtifactInstallerException
-     * @throws InterruptedException The InterruptedException
+     * @throws InterruptedException          The InterruptedException
      */
     public void installTheCsar(CsarHandler csar) throws SdcArtifactInstallerException, InterruptedException {
         logger.info("Installing the CSAR " + csar.getFilePath());
-        installTheLoop(csar, installTheService(csar));
+        installTheLoop(csar, csarServiceInstaller.installTheService(csar));
         logger.info("Successfully installed the CSAR " + csar.getFilePath());
     }
 
     /**
      * Install the Loop from the csar.
      * 
-     * @param csar The Csar Handler
+     * @param csar    The Csar Handler
      * @param service The service object that is related to the loop
      * @throws SdcArtifactInstallerException The SdcArtifactInstallerException
-     * @throws InterruptedException The InterruptedException
+     * @throws InterruptedException          The InterruptedException
      */
-    @Transactional(propagation = Propagation.REQUIRED)
-    public void installTheLoop(CsarHandler csar, Service service) 
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
+    public void installTheLoop(CsarHandler csar, Service service)
             throws SdcArtifactInstallerException, InterruptedException {
         try {
             logger.info("Installing the Loops");
@@ -160,30 +146,6 @@
         }
     }
 
-    /**
-     * Install the Service from the csar.
-     * 
-     * @param csar The Csar Handler
-     * @return The service object
-     */
-    @Transactional
-    public Service installTheService(CsarHandler csar) {
-        logger.info("Start to install the Service from csar");
-        JsonObject serviceDetails = JsonUtils.GSON.fromJson(
-                JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class);
-
-        // Add properties details for each type, VfModule, VF, VFC, ....
-        JsonObject resourcesProp = createServicePropertiesByType(csar);
-        resourcesProp.add("VFModule", createVfModuleProperties(csar));
-
-        Service modelService = new Service(serviceDetails, resourcesProp, 
-                csar.getSdcNotification().getServiceVersion());
-
-        serviceRepository.save(modelService);
-        logger.info("Successfully installed the Service");
-        return modelService;
-    }
-
     private Loop createLoopFromBlueprint(CsarHandler csar, BlueprintArtifact blueprintArtifact, Service service)
             throws IOException, ParseException, InterruptedException {
         Loop newLoop = new Loop();
@@ -243,41 +205,6 @@
         return DcaeDeployParameters.getDcaeDeploymentParametersInJson(blueprintArtifact, newLoop);
     }
 
-    private static JsonObject createVfModuleProperties(CsarHandler csar) {
-        JsonObject vfModuleProps = new JsonObject();
-        // Loop on all Groups defined in the service (VFModule entries type:
-        // org.openecomp.groups.VfModule)
-        for (IEntityDetails entity : csar.getSdcCsarHelper().getEntity(
-                EntityQuery.newBuilder(EntityTemplateType.GROUP).build(),
-                TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build(), false)) {
-            // Get all metadata info
-            JsonObject allVfProps = (JsonObject) JsonUtils.GSON.toJsonTree(entity.getMetadata().getAllProperties());
-            vfModuleProps.add(entity.getMetadata().getAllProperties().get("vfModuleModelName"), allVfProps);
-            // now append the properties section so that we can also have isBase,
-            // volume_group, etc ... fields under the VFmodule name
-            for (Entry<String, Property> additionalProp : entity.getProperties().entrySet()) {
-                allVfProps.add(additionalProp.getValue().getName(),
-                        JsonUtils.GSON.toJsonTree(additionalProp.getValue().getValue()));
-            }
-        }
-        return vfModuleProps;
-    }
-
-    private static JsonObject createServicePropertiesByType(CsarHandler csar) {
-        JsonObject resourcesProp = new JsonObject();
-        // Iterate on all types defined in the tosca lib
-        for (SdcTypes type : SdcTypes.values()) {
-            JsonObject resourcesPropByType = new JsonObject();
-            // For each type, get the metadata of each nodetemplate
-            for (NodeTemplate nodeTemplate : csar.getSdcCsarHelper().getServiceNodeTemplateBySdcType(type)) {
-                resourcesPropByType.add(nodeTemplate.getName(),
-                        JsonUtils.GSON.toJsonTree(nodeTemplate.getMetaData().getAllProperties()));
-            }
-            resourcesProp.add(type.getValue(), resourcesPropByType);
-        }
-        return resourcesProp;
-    }
-
     /**
      * ll get the latest version of the artifact (version can be specified to DCAE
      * call).
diff --git a/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java b/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java
new file mode 100644
index 0000000..277fe00
--- /dev/null
+++ b/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.loop.service;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.google.gson.JsonObject;
+
+import java.util.Map.Entry;
+
+import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
+import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
+import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.sdc.tosca.parser.api.IEntityDetails;
+import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
+import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
+import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+@Component
+@Qualifier("csarInstaller")
+public class CsarServiceInstaller {
+    private static final EELFLogger logger = EELFManager.getInstance().getLogger(CsarServiceInstaller.class);
+
+    @Autowired
+    ServiceRepository serviceRepository;
+
+    /**
+     * Install the Service from the csar.
+     * 
+     * @param csar The Csar Handler
+     * @return The service object
+     */
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
+    public Service installTheService(CsarHandler csar) {
+        logger.info("Start to install the Service from csar");
+        JsonObject serviceDetails = JsonUtils.GSON.fromJson(
+                JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class);
+
+        // Add properties details for each type, VfModule, VF, VFC, ....
+        JsonObject resourcesProp = createServicePropertiesByType(csar);
+        resourcesProp.add("VFModule", createVfModuleProperties(csar));
+
+        Service modelService = new Service(serviceDetails, resourcesProp,
+                csar.getSdcNotification().getServiceVersion());
+
+        serviceRepository.save(modelService);
+        logger.info("Successfully installed the Service");
+        return modelService;
+    }
+
+    private static JsonObject createServicePropertiesByType(CsarHandler csar) {
+        JsonObject resourcesProp = new JsonObject();
+        // Iterate on all types defined in the tosca lib
+        for (SdcTypes type : SdcTypes.values()) {
+            JsonObject resourcesPropByType = new JsonObject();
+            // For each type, get the metadata of each nodetemplate
+            for (NodeTemplate nodeTemplate : csar.getSdcCsarHelper().getServiceNodeTemplateBySdcType(type)) {
+                resourcesPropByType.add(nodeTemplate.getName(),
+                        JsonUtils.GSON.toJsonTree(nodeTemplate.getMetaData().getAllProperties()));
+            }
+            resourcesProp.add(type.getValue(), resourcesPropByType);
+        }
+        return resourcesProp;
+    }
+
+    private static JsonObject createVfModuleProperties(CsarHandler csar) {
+        JsonObject vfModuleProps = new JsonObject();
+        // Loop on all Groups defined in the service (VFModule entries type:
+        // org.openecomp.groups.VfModule)
+        for (IEntityDetails entity : csar.getSdcCsarHelper().getEntity(
+                EntityQuery.newBuilder(EntityTemplateType.GROUP).build(),
+                TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build(), false)) {
+            // Get all metadata info
+            JsonObject allVfProps = (JsonObject) JsonUtils.GSON.toJsonTree(entity.getMetadata().getAllProperties());
+            vfModuleProps.add(entity.getMetadata().getAllProperties().get("vfModuleModelName"), allVfProps);
+            // now append the properties section so that we can also have isBase,
+            // volume_group, etc ... fields under the VFmodule name
+            for (Entry<String, Property> additionalProp : entity.getProperties().entrySet()) {
+                allVfProps.add(additionalProp.getValue().getName(),
+                        JsonUtils.GSON.toJsonTree(additionalProp.getValue().getValue()));
+            }
+        }
+        return vfModuleProps;
+    }
+
+    /**
+     * Verify whether Service in Csar is deployed.
+     * 
+     * @param csar The Csar Handler
+     * @return The flag indicating whether Service is deployed
+     * @throws SdcArtifactInstallerException The SdcArtifactInstallerException
+     */
+    public boolean isServiceAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException {
+        boolean alreadyInstalled = true;
+        JsonObject serviceDetails = JsonUtils.GSON.fromJson(
+                JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class);
+        alreadyInstalled = serviceRepository.existsById(serviceDetails.get("UUID").getAsString());
+
+        return alreadyInstalled;
+    }
+}
