Index: trunk/src/org/expeditee/gui/FrameIO.java
===================================================================
--- trunk/src/org/expeditee/gui/FrameIO.java	(revision 1218)
+++ trunk/src/org/expeditee/gui/FrameIO.java	(revision 1219)
@@ -37,9 +37,12 @@
 import java.util.HashMap;
 import java.util.LinkedList;
+import java.util.List;
 
 import org.expeditee.actions.Actions;
 import org.expeditee.agents.ExistingFramesetException;
-import org.expeditee.auth.io.EncryptedExpReader;
-import org.expeditee.auth.io.EncryptedExpWriter;
+import org.expeditee.auth.Authenticator;
+import org.expeditee.auth.EncryptedExpReader;
+import org.expeditee.auth.EncryptedProfileExpWriter;
+import org.expeditee.auth.gui.MailBay;
 import org.expeditee.io.Conversion;
 import org.expeditee.io.ExpReader;
@@ -193,8 +196,6 @@
 	}
 	
-	public static String FRAMESET_CONSULT_PATH = null;
-
 	public static Frame LoadFrame(String frameName) {
-		return LoadFrame(frameName, FRAMESET_CONSULT_PATH, false);
+		return LoadFrame(frameName, null, false);
 	}
 
@@ -203,6 +204,5 @@
 	}
 
-	public static Frame LoadFrame(String frameName, String path, boolean ignoreAnnotations)
-	{
+	public static Frame LoadFrame(String frameName, String path, boolean ignoreAnnotations)	{
 		if (!isValidFrameName(frameName)) {
 			return null;
@@ -261,5 +261,4 @@
 				Logger.Log(Logger.SYSTEM, Logger.LOAD, "Clearing " + frameName
 						+ " from cache.");
-				Frame frame = _Cache.get(frameNameLower);
 				_Cache.remove(frameNameLower);				
 			}
@@ -293,6 +292,13 @@
 			loaded = LoadKnowPath(knownPath, framename);
 		} else {
-
-			for (String path : FolderSettings.FrameDirs.get()) {
+			List<String> directoriesToSearch = FolderSettings.FrameDirs.get();
+			
+			if (UserSettings.Authenticated.get()) {
+				// if we are running Expeditee Authenticated, consult user profile as location for framesets first
+				String profilePath = FrameIO.PROFILE_PATH + UserSettings.UserName.get() + File.separator;
+				directoriesToSearch.add(0, profilePath);
+			} 
+			
+			for (String path : directoriesToSearch) {
 				loaded = LoadKnowPath(path, framename);
 				if (loaded != null) {
@@ -448,4 +454,5 @@
 				}
 			}
+			reader.close();
 		} catch (FileNotFoundException e) {
 			e.printStackTrace();
@@ -468,5 +475,6 @@
 			if (fullPath.endsWith(ExpReader.EXTENTION)) {
 				if (EncryptedExpReader.isEncryptedExpediteeFile(fullPath)) {
-					reader = new EncryptedExpReader(frameName);
+					final boolean isProfile = frameName.startsWith(UserSettings.UserName.get());
+					reader = new EncryptedExpReader(frameName, isProfile);
 				} else {
 					reader = new ExpReader(frameName);
@@ -941,4 +949,8 @@
 	public static String SaveFrame(Frame toSave, boolean inc,
 			boolean checkBackup) {
+		
+		if (toSave.getName().startsWith("ExpediteeMail")) {
+			System.err.println();
+		}
 
 		// TODO When loading a frame maybe append onto the event history too-
@@ -994,7 +1006,14 @@
 			// if its a new frame or an existing Exp frame...
 			if (fullPath == null || fullPath.endsWith(ExpReader.EXTENTION)) {
-				//writer = new ExpWriter();
-				writer = new ExpWriter();//new EncryptedExpWriter();
-				savedVersion = ExpReader.getVersion(fullPath);
+				//Frame currentFrame = DisplayController.getCurrentFrame();
+				if (UserSettings.Authenticated.get() && 
+						toSave.getName().startsWith(UserSettings.UserName.get()) && 
+						toSave.getNumber() != Authenticator.PUBLIC_KEY_FRAME) {
+					writer = new EncryptedProfileExpWriter();
+					savedVersion = EncryptedExpReader.getVersion(fullPath);
+				} else {
+					writer = new ExpWriter();
+					savedVersion = ExpReader.getVersion(fullPath);
+				}
 			} else {
 				writer = new KMSWriter();
@@ -1016,7 +1035,9 @@
 
 			// Check if we are trying to save an out of date version
-			if (savedVersion > toSave.getVersion()
-					&& !toSave.getFramesetName().equalsIgnoreCase(
-							MessageBay.MESSAGES_FRAMESET_NAME)) {
+			String framesetName = toSave.getFramesetName();
+			boolean isBayFrameset = 
+					framesetName.equalsIgnoreCase(MessageBay.MESSAGES_FRAMESET_NAME) || 
+					framesetName.equalsIgnoreCase(MailBay.EXPEDITEE_MAIL_FRAMESET_NAME);
+			if (savedVersion > toSave.getVersion() && !isBayFrameset) {
 				// remove this frame from the cache if it is there
 				// This will make sure links to the original are set correctly
@@ -1146,6 +1167,4 @@
 		
 		String sf = SaveFrame(toSave, inc, checkBackup);		
-		String originalFrameName = toSave.getFramesetName();
-		//System.out.println(originalFrameName + " : " + toSave.getPath());
 		String fullPath = getFrameFullPathName(toSave.getPath(), toSave
 				.getName());
