diff --git a/apps/sam/java/src/net/i2p/sam/SAMBridge.java b/apps/sam/java/src/net/i2p/sam/SAMBridge.java
index 905ae808d0724f4329180247c76e23928b5455d5..f62e28187f3955be2d02313bd274791c3f8b4a41 100644
--- a/apps/sam/java/src/net/i2p/sam/SAMBridge.java
+++ b/apps/sam/java/src/net/i2p/sam/SAMBridge.java
@@ -42,6 +42,7 @@ import net.i2p.data.Destination;
 import net.i2p.util.I2PAppThread;
 import net.i2p.util.I2PSSLSocketFactory;
 import net.i2p.util.Log;
+import net.i2p.util.OrderedProperties;
 import net.i2p.util.PortMapper;
 import net.i2p.util.SystemVersion;
 
@@ -255,59 +256,51 @@ public class SAMBridge implements Runnable, ClientApp {
     
     /**
      * Load up the keys from the persistFilename.
-     * TODO use DataHelper
-     * TODO store in config dir, not base dir
      */
+    @SuppressWarnings("unchecked")
     private void loadKeys() {
         synchronized (nameToPrivKeys) {
             nameToPrivKeys.clear();
-            BufferedReader br = null;
+            File file = new File(persistFilename);
+            // now in config dir but check base dir too...
+            if (!file.exists()) {
+                if (file.isAbsolute())
+                    return;
+                file = new File(I2PAppContext.getGlobalContext().getConfigDir(), persistFilename);
+                if (!file.exists())
+                    return;
+            }
             try {
-                br = new BufferedReader(new InputStreamReader(
-                        new FileInputStream(persistFilename), "UTF-8"));
-                String line = null;
-                while ( (line = br.readLine()) != null) {
-                    int eq = line.indexOf('=');
-                    String name = line.substring(0, eq);
-                    String privKeys = line.substring(eq+1);
-                    nameToPrivKeys.put(name, privKeys);
-                }
+                Properties props = new Properties();
+                DataHelper.loadProps(props, file);
+                // unchecked
+                Map foo = props;
+                nameToPrivKeys.putAll(foo);
                 if (_log.shouldInfo())
-                    _log.info("Loaded " + nameToPrivKeys.size() + " private keys from " + persistFilename);
-            } catch (FileNotFoundException fnfe) {
-                _log.warn("Key file does not exist at " + persistFilename);
+                    _log.info("Loaded " + nameToPrivKeys.size() + " private keys from " + file);
             } catch (IOException ioe) {
-                _log.error("Unable to read the keys from " + persistFilename, ioe);
-            } finally {
-                if (br != null) try { br.close(); } catch (IOException ioe) {}
+                _log.error("Unable to read the keys from " + file, ioe);
             }
         }
     }
     
     /**
      * Store the current keys to disk in the location specified on creation.
-     * TODO use DataHelper
-     * TODO store in config dir, not base dir
      */
     private void storeKeys() {
         synchronized (nameToPrivKeys) {
-            FileOutputStream out = null;
+            File file = new File(persistFilename);
+            // now in config dir but check base dir too...
+            if (!file.exists() && !file.isAbsolute())
+                file = new File(I2PAppContext.getGlobalContext().getConfigDir(), persistFilename);
             try {
-                out = new FileOutputStream(persistFilename);
-                for (Map.Entry<String, String> entry : nameToPrivKeys.entrySet()) {
-                    String name = entry.getKey();
-                    String privKeys = entry.getValue();
-                    out.write(name.getBytes("UTF-8"));
-                    out.write('=');
-                    out.write(privKeys.getBytes("UTF-8"));
-                    out.write('\n');
-                }
+                Properties props = new OrderedProperties();
+                props.putAll(nameToPrivKeys);
+                DataHelper.storeProps(props, file);
                 if (_log.shouldInfo())
-                    _log.info("Saved " + nameToPrivKeys.size() + " private keys to " + persistFilename);
+                    _log.info("Saved " + nameToPrivKeys.size() + " private keys to " + file);
             } catch (IOException ioe) {
-                _log.error("Error writing out the SAM keys to " + persistFilename, ioe);
-            } finally {
-                if (out != null) try { out.close(); } catch (IOException ioe) {}
+                _log.error("Error writing out the SAM keys to " + file, ioe);
             }
         }
     }