diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java
index 4d920e6..072a6f4 100755
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/CachedDataSource.java
@@ -123,7 +123,7 @@
 				connection = null;
 			}
 
-			monitor.deregisterReguest(testObject);
+			monitor.deregisterRequest(testObject);
 		}
 	}
 
@@ -153,7 +153,7 @@
 				connection = null;
 			}
 
-			monitor.deregisterReguest(testObject);
+			monitor.deregisterRequest(testObject);
 		}
 	}
 
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
index 014dab3..e7a94e6 100755
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java
@@ -884,7 +884,7 @@
 			CachedDataSource first = snapshot.getFirst();
 			CachedDataSource last = snapshot.getLast();
 
-			int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount();
+			int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount();
 			if(delta < 0) {
 				flipper.set(false);
 			} else if(delta > 0) {
@@ -921,7 +921,7 @@
 			CachedDataSource first = snapshot.getFirst();
 			CachedDataSource last = snapshot.getLast();
 
-			int delta = first.getMonitor().getPorcessedConnectionsCount() - last.getMonitor().getPorcessedConnectionsCount();
+			int delta = first.getMonitor().getProcessedConnectionsCount() - last.getMonitor().getProcessedConnectionsCount();
 			if(delta < 0) {
 				flipper.set(false);
 			} else if(delta > 0) {
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java
index 3caa776..c350357 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/factory/DBConfigFactory.java
@@ -24,7 +24,6 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Properties;
-
 import org.onap.ccsdk.sli.core.dblib.config.BaseDBConfiguration;
 import org.onap.ccsdk.sli.core.dblib.config.DbConfigPool;
 import org.onap.ccsdk.sli.core.dblib.config.JDBCConfiguration;
@@ -39,61 +38,66 @@
  */
 public class DBConfigFactory {
 
-	public static DbConfigPool createConfig(Properties resource) {
-		return getConfigparams(resource);
-	}
+    public static DbConfigPool createConfig(Properties resource) {
+        return getConfigparams(resource);
+    }
 
-	static DbConfigPool getConfigparams(Properties properties){
-		DbConfigPool xmlConfig = new DbConfigPool(properties);
-		ArrayList<Properties> propertySets = new ArrayList<Properties>();
+    static DbConfigPool getConfigparams(Properties properties) {
+        DbConfigPool xmlConfig = new DbConfigPool(properties);
+        ArrayList<Properties> propertySets = new ArrayList<Properties>();
 
-		if("JDBC".equalsIgnoreCase(xmlConfig.getType())) {
-			String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS);
-			if(hosts == null || hosts.isEmpty()) {
-				propertySets.add(properties);
-			} else {
-				String[] newhost = hosts.split(",");
-				for(int i=0; i< newhost.length; i++) {
-					Properties localset = new Properties();
-					localset.putAll(properties);
-					String url = localset.getProperty(BaseDBConfiguration.DATABASE_URL);
-					if(url.contains("DBHOST"))
-						url = url.replace("DBHOST", newhost[i]);
-					if(url.contains("dbhost"))
-						url = url.replace("dbhost", newhost[i]);
-					localset.setProperty(BaseDBConfiguration.DATABASE_URL, url);
-					localset.setProperty(BaseDBConfiguration.CONNECTION_NAME, newhost[i]);
-					propertySets.add(localset);
-				}
-			}
-		} else {
-			propertySets.add(properties);
-		}
-		try {
-			Iterator<Properties>  it = propertySets.iterator();
-			while(it.hasNext()) {
-				BaseDBConfiguration config = parse(it.next());
-				xmlConfig.addConfiguration(config);
-			}
+        if ("JDBC".equalsIgnoreCase(xmlConfig.getType())) {
+            String hosts = properties.getProperty(BaseDBConfiguration.DATABASE_HOSTS);
+            if (hosts == null || hosts.isEmpty()) {
+                propertySets.add(properties);
+            } else {
+                setPropertyWhenHostsNonEmpty(hosts, properties, propertySets);
+            }
+        } else {
+            propertySets.add(properties);
+        }
+        try {
+            Iterator<Properties> it = propertySets.iterator();
+            while (it.hasNext()) {
+                BaseDBConfiguration config = parse(it.next());
+                xmlConfig.addConfiguration(config);
+            }
+        } catch (Exception e) {
+            LoggerFactory.getLogger(DBConfigFactory.class).warn("", e);
+        }
 
-		} catch (Exception e) {
-			LoggerFactory.getLogger(DBConfigFactory.class).warn("",e);
-		}
+        return xmlConfig;
+    }
 
-		return xmlConfig;
-	}
+    private static void setPropertyWhenHostsNonEmpty(String hosts, Properties properties, ArrayList<Properties>
+        propertySets) {
+        String[] newhost = hosts.split(",");
+        for (String aNewhost : newhost) {
+            Properties localSet = new Properties();
+            localSet.putAll(properties);
+            String url = localSet.getProperty(BaseDBConfiguration.DATABASE_URL);
+            if (url.contains("DBHOST")) {
+                url = url.replace("DBHOST", aNewhost);
+            }
+            if (url.contains("dbhost")) {
+                url = url.replace("dbhost", aNewhost);
+            }
+            localSet.setProperty(BaseDBConfiguration.DATABASE_URL, url);
+            localSet.setProperty(BaseDBConfiguration.CONNECTION_NAME, aNewhost);
+            propertySets.add(localSet);
+        }
+    }
 
-	public static BaseDBConfiguration parse(Properties props) throws Exception {
+    public static BaseDBConfiguration parse(Properties props) throws Exception {
 
-		String type = props.getProperty(BaseDBConfiguration.DATABASE_TYPE);
+        String type = props.getProperty(BaseDBConfiguration.DATABASE_TYPE);
 
-		BaseDBConfiguration config = null;
+        BaseDBConfiguration config = null;
 
-		if("JDBC".equalsIgnoreCase(type)) {
-			config = new JDBCConfiguration(props);
-		}
+        if ("JDBC".equalsIgnoreCase(type)) {
+            config = new JDBCConfiguration(props);
+        }
 
-		return config;
-
-	}
+        return config;
+    }
 }
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java
index bcd4360..95172ad 100644
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/pm/SQLExecutionMonitor.java
@@ -23,6 +23,7 @@
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Objects;
 import java.util.Observable;
 import java.util.Observer;
 import java.util.SortedSet;
@@ -30,208 +31,190 @@
 import java.util.TimerTask;
 import java.util.TreeSet;
 import java.util.concurrent.atomic.AtomicLong;
-
 import org.onap.ccsdk.sli.core.dblib.DBResourceObserver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SQLExecutionMonitor extends Observable
-{
-	private static Logger LOGGER = LoggerFactory.getLogger(SQLExecutionMonitor.class);
-	
-	final static long MILISECOND = 1000000L;
-	final static long SECOND = 1000L*MILISECOND;
-	
-	private final Timer timer;
-	// collection
-	private final SortedSet<TestObject> innerSet;
-	private SQLExecutionMonitorObserver parent = null; 
-	private final AtomicLong completionCounter;
-	private boolean activeState = false;
-	private final long interval;
-	private final long initialDelay;
-	private final long EXPECTED_TIME_TO_COMPLETE;
-	private final long UNPROCESSED_FAILOVER_THRESHOLD;
+public class SQLExecutionMonitor extends Observable {
 
-	private final class MonitoringTask extends TimerTask 
-	{
-		
-		public void run() 
-		{
-			try {
-				TestObject testObj = new TestObject();
-				testObj.setStartTime(testObj.getStartTime() - EXPECTED_TIME_TO_COMPLETE);
+    private static final Logger LOGGER = LoggerFactory.getLogger(SQLExecutionMonitor.class);
 
-				// take a snapshot of the current task list
-				TestObject[] array = innerSet.toArray(new TestObject[0]);
-				SortedSet<TestObject> copyCurrent = new TreeSet<TestObject>(Arrays.asList(array));
-				// get the list of the tasks that are older than the specified
-				// interval.
-				SortedSet<TestObject> unprocessed = copyCurrent.headSet(testObj);
+    static final long MILISECOND = 1000000L;
+    static final long SECOND = 1000L * MILISECOND;
 
-				long succesfulCount = completionCounter.get();
-				int unprocessedCount = unprocessed.size();
-				
-				if (!unprocessed.isEmpty() && unprocessedCount > UNPROCESSED_FAILOVER_THRESHOLD && succesfulCount == 0)
-				{
-					// switch the Connection Pool to passive
-					setChanged();
-					notifyObservers("Open JDBC requests=" + unprocessedCount+" in "+SQLExecutionMonitor.this.parent.getDbConnectionName());
-				}
-			} catch (Exception exc) {
-				LOGGER.error("", exc);
-			} finally {
-				completionCounter.set(0L);
-			}
-		}
-	}
+    private final Timer timer;
+    // collection
+    private final SortedSet<TestObject> innerSet;
+    private SQLExecutionMonitorObserver parent = null;
+    private final AtomicLong completionCounter;
+    private boolean activeState = false;
+    private final long interval;
+    private final long initialDelay;
+    private final long EXPECTED_TIME_TO_COMPLETE;
+    private final long UNPROCESSED_FAILOVER_THRESHOLD;
 
-	public static class TestObject implements Comparable<TestObject>, Serializable 
-	{
+    private final class MonitoringTask extends TimerTask {
 
-		private static final long serialVersionUID = 1L;
-		private long starttime;
-		private long randId;
+        public void run() {
+            try {
+                TestObject testObj = new TestObject();
+                testObj.setStartTime(testObj.getStartTime() - EXPECTED_TIME_TO_COMPLETE);
 
-		public TestObject()
-		{
-			starttime = System.nanoTime();
-		}
+                // take a snapshot of the current task list
+                TestObject[] array = innerSet.toArray(new TestObject[0]);
+                SortedSet<TestObject> copyCurrent = new TreeSet<>(Arrays.asList(array));
+                // get the list of the tasks that are older than the specified
+                // interval.
+                SortedSet<TestObject> unprocessed = copyCurrent.headSet(testObj);
 
-		public long getStartTime()
-		{
-			return starttime;
-		}
+                long successfulCount = completionCounter.get();
+                int unprocessedCount = unprocessed.size();
 
-		public void setStartTime(long newTime) 
-		{
-			starttime = newTime;
-		}
+                if (!unprocessed.isEmpty() && unprocessedCount > UNPROCESSED_FAILOVER_THRESHOLD
+                    && successfulCount == 0) {
+                    // switch the Connection Pool to passive
+                    setChanged();
+                    notifyObservers("Open JDBC requests=" + unprocessedCount + " in " + SQLExecutionMonitor.this.parent
+                        .getDbConnectionName());
+                }
+            } catch (Exception exc) {
+                LOGGER.error("", exc);
+            } finally {
+                completionCounter.set(0L);
+            }
+        }
+    }
 
-		public int compareTo(TestObject o)
-		{
-			if( this == o)
-				return 0;
-			if(this.starttime > o.getStartTime())
-				return 1;
-			if(this.starttime < o.getStartTime())
-				return -1;
+    public static class TestObject implements Comparable<TestObject>, Serializable {
 
-			if(this.hashCode() > o.hashCode())
-				return 1;
-			if(this.hashCode() < o.hashCode())
-				return -1;
+        private static final long serialVersionUID = 1L;
+        private long startTime;
+        private long randId;
 
-			return 0;
-		}
+        public TestObject() {
+            startTime = System.nanoTime();
+        }
 
-		public String toString()
-		{
-			return Long.toString(starttime)+"#"+ this.hashCode();
-		}
-	
-		public boolean equals(Object obj)
-		{
-			if (this == obj)
-				return true;
+        public long getStartTime() {
+            return startTime;
+        }
 
-			return (obj instanceof TestObject 
-		            && starttime == ((TestObject) obj).getStartTime()
-		            && hashCode() == ((TestObject) obj).hashCode());		
-		}
-	}
+        public void setStartTime(long newTime) {
+            startTime = newTime;
+        }
 
-	public SQLExecutionMonitor(SQLExecutionMonitorObserver parent)
-	{
-		this.parent = parent;
-		completionCounter = new AtomicLong(0L);
-		interval = parent.getInterval();
-		initialDelay = parent.getInitialDelay();
-		this.UNPROCESSED_FAILOVER_THRESHOLD = parent.getUnprocessedFailoverThreshold();
-		this.EXPECTED_TIME_TO_COMPLETE = parent.getExpectedCompletionTime()*MILISECOND;
-		
-		innerSet = Collections.synchronizedSortedSet(new TreeSet<TestObject>());
-		timer = new Timer();
-	}
-	
-	public void cleanup()
-	{
-		timer.cancel();
-	}
-	
-	// registerRequest
-	public TestObject registerRequest()
-	{
-		if(activeState)
-		{
-			TestObject test = new TestObject();
-			if(innerSet.add(test))
-				return test;
-		}
-		return null;
-	}
+        public int compareTo(TestObject o) {
+            if (this == o) {
+                return 0;
+            }
+            if (this.startTime > o.getStartTime()) {
+                return 1;
+            }
+            if (this.startTime < o.getStartTime()) {
+                return -1;
+            }
 
-	// deregisterSuccessfulReguest
-	public boolean deregisterReguest(TestObject test)
-	{
-		if(test == null)
-			return false;
-		// remove from the collection
-		if(innerSet.remove(test) && activeState)
-		{
-			completionCounter.incrementAndGet();
-			return true;
-		}
-		return false; 
-	}
+            if (this.hashCode() > o.hashCode()) {
+                return 1;
+            }
+            if (this.hashCode() < o.hashCode()) {
+                return -1;
+            }
 
-	public void terminate() {
-		timer.cancel();
-	}
+            return 0;
+        }
 
-	/**
-	 * @return the parent
-	 */
-	public final Object getParent() {
-		return parent;
-	}
-	
-	public void addObserver(Observer observer)
-	{
-		if(observer instanceof DBResourceObserver)
-		{
-			DBResourceObserver dbObserver = (DBResourceObserver)observer;
-			if(dbObserver.isMonitorDbResponse())
-			{
-				if(countObservers() == 0)
-				{
-					TimerTask remindTask = new MonitoringTask();
-					timer.schedule(remindTask, initialDelay, interval);
-					activeState = true;
-				}
-			}
-		}
-		super.addObserver(observer);
-	}
-	
-	public void deleteObserver(Observer observer)
-	{
-		super.deleteObserver(observer);
-		if(observer instanceof DBResourceObserver)
-		{
-			DBResourceObserver dbObserver = (DBResourceObserver)observer;
-			if(dbObserver.isMonitorDbResponse())
-			{
-				if(countObservers() == 0)
-				{
-					timer.cancel();
-					activeState = false;
-				}
-			}
-		}
-	}
-	
-	public final int getPorcessedConnectionsCount() {
-		return innerSet.size();
-	}
+        public String toString() {
+            return Long.toString(startTime) + "#" + this.hashCode();
+        }
+
+        public int hashCode() {
+            return Objects.hash(startTime, randId);
+        }
+
+        public boolean equals(Object obj) {
+            return this == obj || (obj instanceof TestObject && startTime == ((TestObject) obj).getStartTime()
+                && hashCode() == obj.hashCode());
+        }
+    }
+
+    public SQLExecutionMonitor(SQLExecutionMonitorObserver parent) {
+        this.parent = parent;
+        completionCounter = new AtomicLong(0L);
+        interval = parent.getInterval();
+        initialDelay = parent.getInitialDelay();
+        this.UNPROCESSED_FAILOVER_THRESHOLD = parent.getUnprocessedFailoverThreshold();
+        this.EXPECTED_TIME_TO_COMPLETE = parent.getExpectedCompletionTime() * MILISECOND;
+
+        innerSet = Collections.synchronizedSortedSet(new TreeSet<TestObject>());
+        timer = new Timer();
+    }
+
+    public void cleanup() {
+        timer.cancel();
+    }
+
+    // registerRequest
+    public TestObject registerRequest() {
+        if (activeState) {
+            TestObject test = new TestObject();
+            if (innerSet.add(test)) {
+                return test;
+            }
+        }
+        return null;
+    }
+
+    // deregisterSuccessfulRequest
+    public boolean deregisterRequest(TestObject test) {
+        if (test == null) {
+            return false;
+        }
+        // remove from the collection
+        if (innerSet.remove(test) && activeState) {
+            completionCounter.incrementAndGet();
+            return true;
+        }
+        return false;
+    }
+
+    public void terminate() {
+        timer.cancel();
+    }
+
+    /**
+     * @return the parent
+     */
+    public final Object getParent() {
+        return parent;
+    }
+
+    @Override
+    public void addObserver(Observer observer) {
+        if (observer instanceof DBResourceObserver) {
+            DBResourceObserver dbObserver = (DBResourceObserver) observer;
+            if (dbObserver.isMonitorDbResponse() && countObservers() == 0) {
+                TimerTask remindTask = new MonitoringTask();
+                timer.schedule(remindTask, initialDelay, interval);
+                activeState = true;
+            }
+        }
+        super.addObserver(observer);
+    }
+
+    @Override
+    public void deleteObserver(Observer observer) {
+        super.deleteObserver(observer);
+        if (observer instanceof DBResourceObserver) {
+            DBResourceObserver dbObserver = (DBResourceObserver) observer;
+            if (dbObserver.isMonitorDbResponse() && countObservers() == 0) {
+                timer.cancel();
+                activeState = false;
+            }
+        }
+    }
+
+    public final int getProcessedConnectionsCount() {
+        return innerSet.size();
+    }
 }
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java
index 160107f..45f6835 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java
@@ -87,28 +87,28 @@
 	
 	public String getNodeName()
 	{
-		return(nodeName);
+		return nodeName;
 	}
 	
 	public String getNodeType()
 	{
-		return(nodeType);
+		return nodeType;
 	}
 	
 	public SvcLogicGraph getGraph()
 	{
-		return(graph);
+		return graph;
 	}
 	
 	public int getNumOutcomes()
 	{
 		if (outcomes == null)
 		{
-			return(0);
+			return 0;
 		}
 		else
 		{
-			return(outcomes.size());
+			return outcomes.size();
 		}
 	}
 	
@@ -116,11 +116,11 @@
 	{
 		if (attributes.containsKey(name))
 		{
-			return(attributes.get(name));
+			return attributes.get(name);
 		}
 		else
 		{
-			return(null);
+			return null;
 		}
 			
 	}
@@ -151,7 +151,7 @@
 		try
 		{
 			SvcLogicExpression parmValue;
-			if ((value == null) || (value.length() == 0))
+			if (value == null || value.length() == 0)
 			{
 				parmValue = new SvcLogicAtom("STRING", "");
 			}
@@ -187,11 +187,11 @@
 	{
 		if (parameters.containsKey(name))
 		{
-			return(parameters.get(name));
+			return parameters.get(name);
 		}
 		else
 		{
-			return(null);
+			return null;
 		}
 	}
 	
@@ -245,7 +245,7 @@
 			return null;
 		}
 		
-		return(outcomes.entrySet());
+		return outcomes.entrySet();
 		
 	}
 	
@@ -256,7 +256,7 @@
 			return null;
 		}
 		
-		return(parameters.entrySet());
+		return parameters.entrySet();
 		
 	}
 	
@@ -346,8 +346,8 @@
 			pstr.print("'`");
 		}
 		
-		if (((parameters == null) || (parameters.isEmpty())) && 
-				((outcomes == null) || outcomes.isEmpty()))
+		if ((parameters == null || parameters.isEmpty()) &&
+				(outcomes == null || outcomes.isEmpty()))
 		{
 			pstr.print("/>\n");
 			pstr.flush();
@@ -424,12 +424,12 @@
 		}
 		if (outcomes == null)
 		{
-			return(null);
+			return null;
 		}
 		
 		if (outcomes.containsKey(value))
 		{
-			return(outcomes.get(value));
+			return outcomes.get(value);
 		}
 		else
 		{
@@ -443,11 +443,11 @@
 
 			if (outcomes.containsKey("Other"))
 			{
-				return(outcomes.get("Other"));
+				return outcomes.get("Other");
 			}
 			else
 			{
-				return(null);
+				return null;
 			}
 		}
 	}
