diff --git a/components/net/sf/briar/plugins/socket/SimpleSocketPlugin.java b/components/net/sf/briar/plugins/socket/SimpleSocketPlugin.java
index 2734a484a340fa33711ede54bfc4ca3793f00164..e8eef01c119e949c950bb6c6492c60c7ee4839d2 100644
--- a/components/net/sf/briar/plugins/socket/SimpleSocketPlugin.java
+++ b/components/net/sf/briar/plugins/socket/SimpleSocketPlugin.java
@@ -36,20 +36,12 @@ public class SimpleSocketPlugin extends SocketPlugin {
 
 	@Override
 	protected SocketAddress getLocalSocketAddress() {
-		Map<String, String> properties;
-		synchronized(this) {
-			properties = localProperties;
-		}
-		if(properties == null) return null;
-		return createSocketAddress(properties);
+		return createSocketAddress(localProperties);
 	}
 
 	@Override
 	protected SocketAddress getSocketAddress(ContactId c) {
-		Map<String, String> properties;
-		synchronized(this) {
-			properties = remoteProperties.get(c);
-		}
+		Map<String, String> properties = remoteProperties.get(c);
 		if(properties == null) return null;
 		return createSocketAddress(properties);
 	}
diff --git a/components/net/sf/briar/plugins/socket/SocketPlugin.java b/components/net/sf/briar/plugins/socket/SocketPlugin.java
index b857fa866fa62cb57af8cb1203368d4d619fb8c0..a7a6c2ae04272b6e3b581280dc95a2d55e06a93f 100644
--- a/components/net/sf/briar/plugins/socket/SocketPlugin.java
+++ b/components/net/sf/briar/plugins/socket/SocketPlugin.java
@@ -24,6 +24,7 @@ abstract class SocketPlugin implements StreamTransportPlugin {
 
 	private volatile boolean started = false;
 
+	// These methods should be called with this's lock held and started == true
 	protected abstract SocketAddress getLocalSocketAddress();
 	protected abstract SocketAddress getSocketAddress(ContactId c);
 	protected abstract Socket createClientSocket();
@@ -49,9 +50,14 @@ abstract class SocketPlugin implements StreamTransportPlugin {
 	protected Runnable createBinder() {
 		return new Runnable() {
 			public void run() {
-				SocketAddress addr = getLocalSocketAddress();
-				if(addr == null) return;
-				Socket s = createServerSocket();
+				SocketAddress addr;
+				Socket s;
+				synchronized(SocketPlugin.this) {
+					if(!started) return;
+					addr = getLocalSocketAddress();
+					s = createServerSocket();
+				}
+				if(addr == null || s == null) return;
 				try {
 					s.bind(addr);
 				} catch(IOException e) {
@@ -102,16 +108,15 @@ abstract class SocketPlugin implements StreamTransportPlugin {
 		};
 	}
 
-	public StreamTransportConnection createConnection(ContactId c) {
-		if(!started) throw new IllegalStateException();
-		return createAndConnectSocket(c);
-	}
-
-	private StreamTransportConnection createAndConnectSocket(ContactId c) {
-		if(!started) return null;
-		SocketAddress addr = getSocketAddress(c);
-		if(addr == null) return null;
-		Socket s = createClientSocket();
+	protected StreamTransportConnection createAndConnectSocket(ContactId c) {
+		SocketAddress addr;
+		Socket s;
+		synchronized(this) {
+			if(!started) return null;
+			addr = getSocketAddress(c);
+			s = createClientSocket();
+		}
+		if(addr == null || s == null) return null;
 		try {
 			s.connect(addr);
 		} catch(IOException e) {
@@ -119,4 +124,9 @@ abstract class SocketPlugin implements StreamTransportPlugin {
 		}
 		return new SocketTransportConnection(s);
 	}
+
+	public StreamTransportConnection createConnection(ContactId c) {
+		if(!started) throw new IllegalStateException();
+		return createAndConnectSocket(c);
+	}
 }