diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdEngine.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdEngine.java
index 425e0bf..1fb2518 100644
--- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdEngine.java
+++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdEngine.java
@@ -66,9 +66,13 @@
  *
  */
 public class StdEngine extends StdPDPItemSetChangeNotifier implements PAPPolicyEngine {
-    public static final String pipPropertyFile = "pip.properties";
+    public static final String PIP_PROPERTY_FILE = "pip.properties";
 
-    private static final String addGroup = "addGroup ";
+    private static final String STR_ADDGROUP = "addGroup ";
+    private static final String STR_CLASS = "StdEngine";
+    private static final String STR_APPEND_NAME = ".name";
+    private static final String STR_APPEND_DESCRIPTION = ".description";
+    private static final String STR_APPEND_PDPS = ".pdps";
 
     private static Log logger = LogFactory.getLog(StdEngine.class);
 
@@ -143,13 +147,13 @@
         if (this.repository == null) {
             throw new PAPException("No repository specified.");
         }
-        if (Files.notExists(this.repository)) {
+        if (! this.repository.toFile().exists()) {
             Files.createDirectory(repository);
         }
-        if (!Files.isDirectory(this.repository)) {
+        if (! this.repository.toFile().isDirectory()) {
             throw new PAPException("Repository is NOT a directory: " + this.repository.toAbsolutePath());
         }
-        if (!Files.isWritable(this.repository)) {
+        if (! this.repository.toFile().canWrite()) {
             throw new PAPException("Repository is NOT writable: " + this.repository.toAbsolutePath());
         }
         //
@@ -177,7 +181,7 @@
             //
             this.groups = this.readProperties(this.repository, properties);
         } catch (IOException e) {
-            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdEngine", "Failed to load properties file");
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS, "Failed to load properties file");
             this.groups = new HashSet<>();
         }
         //
@@ -210,7 +214,7 @@
             //
             // Does it exist?
             //
-            if (Files.notExists(defaultPath)) {
+            if (! defaultPath.toFile().exists()) {
                 //
                 // Create its directory
                 //
@@ -227,7 +231,7 @@
                     try (OutputStream os = Files.newOutputStream(policyPath)) {
                         props.store(os, "");
                     } catch (IOException e) {
-                        PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdEngine",
+                        PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS,
                                 "Failed to write default policy properties");
                     }
                 }
@@ -239,7 +243,7 @@
                     try (OutputStream os = Files.newOutputStream(pipPath)) {
                         props.store(os, "");
                     } catch (IOException e) {
-                        PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdEngine",
+                        PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS,
                                 "Failed to write default pip properties");
                     }
                 }
@@ -247,7 +251,7 @@
             //
             // Create the default group
             //
-            StdPDPGroup newDefault = new StdPDPGroup(defaultId, true, "default",
+            StdPDPGroup newDefault = new StdPDPGroup(defaultId, true, PROP_PAP_GROUPS_DEFAULT_NAME,
                     "The default group where new PDP's are put.", defaultPath);
             //
             // Add it to our list
@@ -266,7 +270,7 @@
                     properties.store(os, "");
                 }
             } catch (IOException e) {
-                PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "StdEngine",
+                PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, STR_CLASS,
                         "Failed to save properties with new default group information.");
             }
             //
@@ -275,7 +279,7 @@
             wasDefaultGroupJustAdded = true;
             return newDefault;
         } catch (IOException e) {
-            PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "StdEngine", "Failed to create default group");
+            PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, STR_CLASS, "Failed to create default group");
             throw new PAPException("Failed to create default group");
         }
     }
@@ -333,7 +337,7 @@
         // If it exists already
         //
         if (Files.exists(groupPath)) {
-            logger.warn(addGroup + id + " directory exists");
+            logger.warn(STR_ADDGROUP + id + " directory exists");
         } else {
             try {
                 //
@@ -341,7 +345,7 @@
                 //
                 Files.createDirectory(groupPath);
             } catch (IOException e) {
-                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdEngine", "Failed to create " + groupPath);
+                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS, "Failed to create " + groupPath);
                 throw new PAPException("Failed to create " + id);
             }
         }
@@ -350,8 +354,8 @@
         //
 
         Path policyProperties = Paths.get(groupPath.toString(), "xacml.policy.properties");
-        if (Files.exists(policyProperties)) {
-            logger.warn(addGroup + id + " file exists");
+        if (policyProperties.toFile().exists()) {
+            logger.warn(STR_ADDGROUP + id + " file exists");
         } else {
             Properties props = new Properties();
             props.setProperty(XACMLProperties.PROP_REFERENCEDPOLICIES, "");
@@ -362,7 +366,7 @@
                     props.store(os, "");
                 }
             } catch (IOException e) {
-                PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "StdEngine", "Failed to create policyProperties");
+                PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, STR_CLASS, "Failed to create policyProperties");
                 throw new PAPException("Failed to create " + id);
             }
         }
@@ -371,8 +375,8 @@
         //
         Path pipProperties = Paths.get(groupPath.toString(), "xacml.pip.properties");
         Properties props = new Properties();
-        if (Files.exists(pipProperties)) {
-            logger.warn(addGroup + id + " file exists.");
+        if (pipProperties.toFile().exists()) {
+            logger.warn(STR_ADDGROUP + id + " file exists.");
         } else {
             try {
                 props = setPipProperties(props);
@@ -381,7 +385,7 @@
                     props.store(os, "");
                 }
             } catch (IOException e) {
-                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdEngine", "Failed to create pipProperties");
+                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS, "Failed to create pipProperties");
                 throw new PAPException("Failed to create " + id);
             }
 
@@ -628,8 +632,8 @@
         List<String> ids = new ArrayList<>();
         for (PDPGroup group : this.groups) {
             ids.add(group.getId());
-            properties.setProperty(group.getId() + ".name", group.getName() == null ? "" : group.getName());
-            properties.setProperty(group.getId() + ".description",
+            properties.setProperty(group.getId() + STR_APPEND_NAME, group.getName() == null ? "" : group.getName());
+            properties.setProperty(group.getId() + STR_APPEND_DESCRIPTION,
                     group.getDescription() == null ? "" : group.getDescription());
             //
             // Iterate its PDPs
@@ -637,8 +641,8 @@
             List<String> pdps = new ArrayList<>();
             for (PDP pdp : group.getPdps()) {
                 pdps.add(pdp.getId());
-                properties.setProperty(pdp.getId() + ".name", pdp.getName() == null ? "" : pdp.getName());
-                properties.setProperty(pdp.getId() + ".description",
+                properties.setProperty(pdp.getId() + STR_APPEND_NAME, pdp.getName() == null ? "" : pdp.getName());
+                properties.setProperty(pdp.getId() + STR_APPEND_DESCRIPTION,
                         pdp.getDescription() == null ? "" : pdp.getDescription());
                 if (pdp instanceof OnapPDP) {
                     properties.setProperty(pdp.getId() + ".jmxport",
@@ -654,7 +658,7 @@
             if (logger.isDebugEnabled()) {
                 logger.debug("Group " + group.getId() + " PDPS: " + pdpList);
             }
-            properties.setProperty(group.getId() + ".pdps", pdpList);
+            properties.setProperty(group.getId() + STR_APPEND_PDPS, pdpList);
         }
         if (ids.isEmpty()) {
             throw new PAPException("Inconsistency - we have NO groups. We should have at least one.");
@@ -720,8 +724,8 @@
         //
         // Set its properties
         //
-        properties.setProperty(group.getId() + ".name", group.getName());
-        properties.setProperty(group.getId() + ".description", group.getDescription());
+        properties.setProperty(group.getId() + STR_APPEND_NAME, group.getName());
+        properties.setProperty(group.getId() + STR_APPEND_DESCRIPTION, group.getDescription());
         //
         // Set its PDP list
         //
@@ -736,9 +740,9 @@
                 }
                 pdpList = Joiner.on(',').skipNulls().join(ids);
             }
-            properties.setProperty(group.getId() + ".pdps", pdpList);
+            properties.setProperty(group.getId() + STR_APPEND_PDPS, pdpList);
         } else {
-            properties.setProperty(group.getId() + ".pdps", "");
+            properties.setProperty(group.getId() + STR_APPEND_PDPS, "");
         }
     }
 
@@ -786,7 +790,7 @@
             //
             this.saveConfiguration();
         } catch (IOException | PAPException e) {
-            PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "StdEngine", "Failed to save configuration");
+            PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, STR_CLASS, "Failed to save configuration");
         }
     }
 
@@ -796,8 +800,8 @@
         props.setProperty("AAF.description", "AAFEngine to communicate with AAF to take decisions");
         props.setProperty("AAF.classname", "org.onap.policy.xacml.std.pip.engines.aaf.AAFEngine");
         // read from PIP properties file.
-        Path file = Paths.get(pipPropertyFile);
-        if (!Files.notExists(file)) {
+        Path file = Paths.get(PIP_PROPERTY_FILE);
+        if (file.toFile().exists()) {
             InputStream in;
             Properties prop = new Properties();
             try {
@@ -947,7 +951,7 @@
                     throw new PAPException("Unable to rename directory; reason unknown");
                 }
             } catch (Exception e) {
-                PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "StdEngine", "Unable to rename directory");
+                PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, STR_CLASS, "Unable to rename directory");
                 throw new PAPException(
                         "Unable to move directory from '" + oldPath + "' to '" + newPath + "': " + e.getMessage(), e);
             }
@@ -1022,7 +1026,7 @@
         //
         // If it exists already
         //
-        if (!Files.exists(groupPath)) {
+        if (! groupPath.toFile().exists()) {
             logger.warn("removeGroup " + id + " directory does not exist" + groupPath.toString());
         } else {
             try {
@@ -1040,7 +1044,7 @@
                 //
                 Files.delete(groupPath);
             } catch (IOException e) {
-                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdEngine", "Failed to delete " + groupPath);
+                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS, "Failed to delete " + groupPath);
                 throw new PAPException("Failed to delete " + id);
             }
         }
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPDPGroup.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPDPGroup.java
index d406a54..daa3764 100644
--- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPDPGroup.java
+++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPDPGroup.java
@@ -59,13 +59,21 @@
 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
 import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier.StdItemSetChangeListener;
 
-@EqualsAndHashCode(callSuper=false)
+@EqualsAndHashCode(callSuper = false)
 @ToString
 public class StdPDPGroup extends StdPDPItemSetChangeNotifier
         implements OnapPDPGroup, StdItemSetChangeListener, Comparable<Object>, Serializable {
 
     private static final long serialVersionUID = 1L;
-    private static final String groupNotExist = "Group directory does NOT exist";
+    private static final String MSG_GROUPNOTEXIST = "Group directory does NOT exist";
+    private static final String MSG_LOADFAILURE = "Failed to load group policy properties file: ";
+    private static final String STR_APPEND_NAME = ".name";
+    private static final String STR_APPEND_DESCRIPTION = ".description";
+    private static final String STR_APPEND_PDPS = ".pdps";
+    private static final String STR_CLASS = "StdPDPGroup";
+    private static final String PROPS_POLICY = "xacml.policy.properties";
+    private static final String PROPS_PIP = "xacml.pip.properties";
+
     private static Log logger = LogFactory.getLog(StdPDPGroup.class);
 
     private String id;
@@ -174,11 +182,11 @@
         //
         for (Object key : properties.keySet()) {
             if (key.toString().startsWith(this.id + ".")) {
-                if (key.toString().endsWith(".name")) {
+                if (key.toString().endsWith(STR_APPEND_NAME)) {
                     this.name = properties.getProperty(key.toString());
-                } else if (key.toString().endsWith(".description")) {
+                } else if (key.toString().endsWith(STR_APPEND_DESCRIPTION)) {
                     this.description = properties.getProperty(key.toString());
-                } else if (key.toString().endsWith(".pdps")) {
+                } else if (key.toString().endsWith(STR_APPEND_PDPS)) {
                     String pdpList = properties.getProperty(key.toString());
                     if (pdpList != null && pdpList.length() > 0) {
                         for (String pdpId : Splitter.on(',').omitEmptyStrings().trimResults().split(pdpList)) {
@@ -197,25 +205,25 @@
         //
         // Validate our directory
         //
-        if (Files.notExists(directory)) {
+        if (! directory.toFile().exists()) {
             logger.warn("Group directory does NOT exist: " + directory.toString());
             try {
                 Files.createDirectory(directory);
-                this.status.addLoadWarning(groupNotExist);
+                this.status.addLoadWarning(MSG_GROUPNOTEXIST);
             } catch (IOException e) {
-                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup", groupNotExist);
-                this.status.addLoadError(groupNotExist);
+                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS, MSG_GROUPNOTEXIST);
+                this.status.addLoadError(MSG_GROUPNOTEXIST);
                 this.status.setStatus(PDPGroupStatus.Status.LOAD_ERRORS);
             }
         }
         //
         // Parse policies
         //
-        this.loadPolicies(Paths.get(directory.toString(), "xacml.policy.properties"));
+        this.loadPolicies(Paths.get(directory.toString(), PROPS_POLICY));
         //
         // Parse pip config
         //
-        this.loadPIPConfig(Paths.get(directory.toString(), "xacml.pip.properties"));
+        this.loadPIPConfig(Paths.get(directory.toString(), PROPS_PIP));
     }
 
     /**
@@ -253,10 +261,10 @@
                 //
                 this.readPolicyProperties(directory, policyProperties);
             } catch (IOException e) {
-                logger.warn("Failed to load group policy properties file: " + file, e);
+                logger.warn(MSG_LOADFAILURE + file, e);
                 this.status.addLoadError("Not policy properties defined");
                 this.status.setStatus(Status.LOAD_ERRORS);
-                throw new PAPException("Failed to load group policy properties file: " + file);
+                throw new PAPException(MSG_LOADFAILURE + file);
             }
         }
     }
@@ -313,7 +321,7 @@
                 logger.warn("Failed to open group PIP Config properties file: " + file, e);
                 this.status.addLoadError("Not PIP config properties defined");
                 this.status.setStatus(Status.LOAD_ERRORS);
-                throw new PAPException("Failed to load group policy properties file: " + file);
+                throw new PAPException(MSG_LOADFAILURE + file);
 
             }
         }
@@ -500,7 +508,7 @@
         for (PDPPolicy policy : this.policies) {
             // for all policies need to tell PDP the "name", which is the base name for the file id
             if (policy.getName() != null) {
-                properties.setProperty(policy.getId() + ".name", policy.getName());
+                properties.setProperty(policy.getId() + STR_APPEND_NAME, policy.getName());
             }
             // put the policy on the correct list
             if (policy.isRoot()) {
@@ -550,7 +558,7 @@
                 try {
                     Files.delete(tempFile);
                 } catch (Exception ee) {
-                    PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, ee, "StdPDPGroup",
+                    PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, ee, STR_CLASS,
                             "Policy was invalid, could NOT delete it.");
                 }
                 throw new PAPException("Policy is invalid");
@@ -568,7 +576,7 @@
             //
             return tempRootPolicy;
         } catch (IOException e) {
-            PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "StdPDPGroup", "Failed to publishPolicy");
+            PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, STR_CLASS, "Failed to publishPolicy");
         }
         return null;
     }
@@ -586,69 +594,18 @@
      * @throws PAPException PAPException
      */
     public void copyPolicyToFile(String id, InputStream policy) throws PAPException {
-        try {
-            //
-            // Copy the policy over
-            //
-            long num;
-            Path policyFilePath = Paths.get(this.directory.toAbsolutePath().toString(), id);
-
-            Path policyFile;
-            if (Files.exists(policyFilePath)) {
-                policyFile = policyFilePath;
-            } else {
-                policyFile = Files.createFile(policyFilePath);
-            }
-
-            try (OutputStream os = Files.newOutputStream(policyFile)) {
-                num = ByteStreams.copy(policy, os);
-            }
-
-            logger.info("Copied " + num + " bytes for policy " + name);
-
-            for (PDPPolicy p : policies) {
-                if (p.getId().equals(id)) {
-                    // we just re-copied/refreshed/updated the policy file for a policy that already exists in this
-                    // group
-                    logger.info("Policy '" + id + "' already exists in group '" + getId() + "'");
-                    return;
-                }
-            }
-
-            // policy is new to this group
-            StdPDPPolicy tempRootPolicy = new StdPDPPolicy(id, true, name, policyFile.toUri());
-            if (!tempRootPolicy.isValid()) {
-                try {
-                    Files.delete(policyFile);
-                } catch (Exception ee) {
-                    PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, ee, "StdPDPGroup",
-                            "Policy was invalid, could NOT delete it.");
-                }
-                throw new PAPException("Policy is invalid");
-            }
-            //
-            // Add it in
-            //
-            this.policies.add(tempRootPolicy);
-            //
-            // We are changed
-            //
-            this.firePDPGroupChanged(this);
-        } catch (IOException e) {
-            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup", "Failed to copyPolicyToFile");
-            throw new PAPException("Failed to copy policy to file: " + e);
-        }
+        copyPolicyToFile(id, this.name, policy);
     }
 
     /**
      * Policy Engine API Copy one policy file into the Group's directory but do not change the configuration.
      *
      * @param id String
-     * @param name String
+     * @param fileName String
      * @param policy InputStream
      * @throws PAPException PAPException
      */
-    public void copyPolicyToFile(String id, String name, InputStream policy) throws PAPException {
+    public void copyPolicyToFile(String id, String fileName, InputStream policy) throws PAPException {
         try {
             //
             // Copy the policy over
@@ -657,7 +614,7 @@
             Path policyFilePath = Paths.get(this.directory.toAbsolutePath().toString(), id);
 
             Path policyFile;
-            if (Files.exists(policyFilePath)) {
+            if (policyFilePath.toFile().exists()) {
                 policyFile = policyFilePath;
             } else {
                 policyFile = Files.createFile(policyFilePath);
@@ -667,7 +624,7 @@
                 num = ByteStreams.copy(policy, os);
             }
 
-            logger.info("Copied " + num + " bytes for policy " + name);
+            logger.info("Copied " + num + " bytes for policy " + fileName);
             for (PDPPolicy p : policies) {
                 if (p.getId().equals(id)) {
                     // we just re-copied/refreshed/updated the policy file for a policy that already exists in this
@@ -678,12 +635,12 @@
             }
 
             // policy is new to this group
-            StdPDPPolicy tempRootPolicy = new StdPDPPolicy(id, true, name, policyFile.toUri());
+            StdPDPPolicy tempRootPolicy = new StdPDPPolicy(id, true, fileName, policyFile.toUri());
             if (!tempRootPolicy.isValid()) {
                 try {
                     Files.delete(policyFile);
                 } catch (Exception ee) {
-                    PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, ee, "StdPDPGroup",
+                    PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, ee, STR_CLASS,
                             "Policy was invalid, could NOT delete it.");
                 }
                 throw new PAPException("Policy is invalid");
@@ -698,7 +655,7 @@
             this.firePDPGroupChanged(this);
 
         } catch (IOException e) {
-            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup", "Failed to copyPolicyToFile");
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS, "Failed to copyPolicyToFile");
             throw new PAPException("Failed to copy policy to file: " + e);
         }
     }
@@ -730,7 +687,7 @@
             this.firePDPGroupChanged(this);
             return true;
         } catch (Exception e) {
-            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup", "Failed to delete policy");
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS, "Failed to delete policy");
         }
         return false;
     }
@@ -762,7 +719,7 @@
             this.firePDPGroupChanged(this);
             return true;
         } catch (Exception e) {
-            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup", "Failed to delete policy " + policy);
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS, "Failed to delete policy " + policy);
         }
         return false;
     }
@@ -817,14 +774,14 @@
         // Validate our directory
         //
         boolean fire = false;
-        if (Files.notExists(directory)) {
+        if (! directory.toFile().exists()) {
             logger.warn("Group directory does NOT exist: " + directory.toString());
             try {
                 Files.createDirectory(directory);
                 fire = true;
                 this.status.addLoadWarning("Created missing group directory");
             } catch (IOException e) {
-                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup",
+                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS,
                         "Failed to create missing Group directory.");
                 this.status.addLoadError("Failed to create missing Group directory.");
                 this.status.setStatus(PDPGroupStatus.Status.LOAD_ERRORS);
@@ -833,14 +790,14 @@
         //
         // Validate our PIP config file
         //
-        Path pipPropertiesFile = Paths.get(directory.toString(), "xacml.pip.properties");
-        if (Files.notExists(pipPropertiesFile)) {
+        Path pipPropertiesFile = Paths.get(directory.toString(), PROPS_PIP);
+        if (! pipPropertiesFile.toFile().exists()) {
             try {
                 Files.createFile(pipPropertiesFile);
                 fire = true;
                 this.status.addLoadWarning("Created missing PIP properties file");
             } catch (IOException e) {
-                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup",
+                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS,
                         "Failed to create missing PIP properties file");
                 this.status.addLoadError("Failed to create missing PIP properties file");
                 this.status.setStatus(PDPGroupStatus.Status.LOAD_ERRORS);
@@ -849,14 +806,14 @@
         //
         // Valid our policy properties file
         //
-        Path policyPropertiesFile = Paths.get(directory.toString(), "xacml.policy.properties");
-        if (Files.notExists(policyPropertiesFile)) {
+        Path policyPropertiesFile = Paths.get(directory.toString(), PROPS_POLICY);
+        if (! policyPropertiesFile.toFile().exists()) {
             try {
                 Files.createFile(policyPropertiesFile);
                 fire = true;
                 this.status.addLoadWarning("Created missing Policy properties file");
             } catch (IOException e) {
-                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup",
+                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS,
                         "Failed to create missing Policy properties file");
                 this.status.addLoadError("Failed to create missing Policy properties file");
                 this.status.setStatus(PDPGroupStatus.Status.LOAD_ERRORS);
@@ -910,7 +867,7 @@
                 try {
                     policy = new StdPDPPolicy(id, isRoot, policyPath.toUri(), properties);
                 } catch (IOException e) {
-                    PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup",
+                    PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS,
                             "Failed to create policy object");
                     policy = null;
                 }
@@ -957,7 +914,7 @@
         try {
             saveGroupConfiguration();
         } catch (PAPException | IOException e) {
-            PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "StdPDPGroup",
+            PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, STR_CLASS,
                     "Unable to save group configuration change");
             // don't notify other things of change if we cannot save it???
             return;
@@ -1019,13 +976,13 @@
 
         // save info about each policy
         for (PDPPolicy policy : this.policies) {
-            policyProperties.put(policy.getId() + ".name", policy.getName());
+            policyProperties.put(policy.getId() + STR_APPEND_NAME, policy.getName());
         }
 
         //
         // Now we can save the file
         //
-        Path file = Paths.get(this.directory.toString(), "xacml.policy.properties");
+        Path file = Paths.get(this.directory.toString(), PROPS_POLICY);
         try (OutputStream os = Files.newOutputStream(file)) {
             policyProperties.store(os, "");
         } catch (Exception e) {
@@ -1039,11 +996,11 @@
         //
         // Now we can save the file
         //
-        file = Paths.get(this.directory.toString(), "xacml.pip.properties");
+        file = Paths.get(this.directory.toString(), PROPS_PIP);
         try (OutputStream os = Files.newOutputStream(file)) {
             pipProperties.store(os, "");
         } catch (Exception e) {
-            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "StdPDPGroup", "Group PIP Config save failed");
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, STR_CLASS, "Group PIP Config save failed");
             throw new PAPException("Failed to save pip properties file '" + file + "'");
         }
     }
@@ -1077,8 +1034,8 @@
         props.setProperty("AAF.classname", "org.onap.policy.xacml.std.pip.engines.aaf.AAFEngine");
         props.setProperty(XACMLProperties.PROP_PIP_ENGINES, "AAF");
         // read from PIP properties file.
-        Path file = Paths.get(StdEngine.pipPropertyFile);
-        if (!Files.notExists(file)) {
+        Path file = Paths.get(StdEngine.PIP_PROPERTY_FILE);
+        if (file.toFile().exists()) {
             InputStream in;
             Properties prop = new Properties();
             try {
