diff --git a/tdt4140-gr1800/app.core/src/main/java/tdt4140/gr1800/app/core/DocumentStorageImpl.java b/tdt4140-gr1800/app.core/src/main/java/tdt4140/gr1800/app/core/DocumentStorageImpl.java
index 9314f27249bf693cb90bcbf07e2c9a2c0a851e60..4e91dfaf9d49c3a455cf0ab11c469198692b901b 100644
--- a/tdt4140-gr1800/app.core/src/main/java/tdt4140/gr1800/app/core/DocumentStorageImpl.java
+++ b/tdt4140-gr1800/app.core/src/main/java/tdt4140/gr1800/app/core/DocumentStorageImpl.java
@@ -31,6 +31,7 @@ public abstract class DocumentStorageImpl<D, L> implements IDocumentStorage<L> {
 	@Override
 	public void openDocument(L storage) throws IOException {
 		setDocument(loadDocument(storage));
+		setDocumentLocation(storage);
 	}
 
 	@Override
@@ -39,8 +40,14 @@ public abstract class DocumentStorageImpl<D, L> implements IDocumentStorage<L> {
 	}
 
 	public void saveDocumentAs(L documentLocation) throws IOException {
+		L oldDocumentLocation = getDocumentLocation();
 		setDocumentLocation(documentLocation);
-		saveDocument();
+		try {
+			saveDocument();
+		} catch (IOException e) {
+			setDocumentLocation(oldDocumentLocation);
+			throw e;
+		}
 	}
 	
 	public void saveCopyAs(L documentLocation) throws IOException {