diff --git a/briar-android-tests/src/test/java/org/briarproject/sync/SimplexMessagingComponent.java b/briar-android-tests/src/test/java/org/briarproject/sync/SimplexMessagingComponent.java
index 1d0a7d70f348b403f8c5712a265385ae706a3483..ea5ae968972378d332fd4f1b062ac72f8e277cff 100644
--- a/briar-android-tests/src/test/java/org/briarproject/sync/SimplexMessagingComponent.java
+++ b/briar-android-tests/src/test/java/org/briarproject/sync/SimplexMessagingComponent.java
@@ -1,6 +1,7 @@
 package org.briarproject.sync;
 
 import org.briarproject.TestDatabaseModule;
+import org.briarproject.TestPluginsModule;
 import org.briarproject.TestSystemModule;
 import org.briarproject.api.contact.ContactManager;
 import org.briarproject.api.db.DatabaseComponent;
@@ -23,6 +24,7 @@ import org.briarproject.event.EventModule;
 import org.briarproject.identity.IdentityModule;
 import org.briarproject.lifecycle.LifecycleModule;
 import org.briarproject.messaging.MessagingModule;
+import org.briarproject.plugins.PluginsModule;
 import org.briarproject.transport.TransportModule;
 
 import javax.inject.Singleton;
@@ -30,23 +32,37 @@ import javax.inject.Singleton;
 import dagger.Component;
 
 @Singleton
-@Component(modules = {TestDatabaseModule.class, TestSystemModule.class,
-		LifecycleModule.class, ContactModule.class, CryptoModule.class,
-		DatabaseModule.class, EventModule.class, SyncModule.class,
-		DataModule.class, TransportModule.class, IdentityModule.class,
-		MessagingModule.class, ClientsModule.class})
+@Component(modules = {TestDatabaseModule.class, TestPluginsModule.class,
+		TestSystemModule.class, LifecycleModule.class, ContactModule.class,
+		CryptoModule.class, DatabaseModule.class, EventModule.class,
+		SyncModule.class, DataModule.class, TransportModule.class,
+		IdentityModule.class, MessagingModule.class, ClientsModule.class,
+		PluginsModule.class})
 public interface SimplexMessagingComponent {
+
 	void inject(SimplexMessagingIntegrationTest testCase);
-	LifecycleManager getLifeCycleManager();
+
+	LifecycleManager getLifecycleManager();
+
 	DatabaseComponent getDatabaseComponent();
+
 	IdentityManager getIdentityManager();
+
 	ContactManager getContactManager();
+
 	MessagingManager getMessagingManager();
+
 	KeyManager getKeyManager();
+
 	PrivateMessageFactory getPrivateMessageFactory();
+
 	PacketWriterFactory getPacketWriterFactory();
+
 	EventBus getEventBus();
+
 	StreamWriterFactory getStreamWriterFactory();
+
 	StreamReaderFactory getStreamReaderFactory();
+
 	PacketReaderFactory getPacketReaderFactory();
 }
diff --git a/briar-android-tests/src/test/java/org/briarproject/sync/SimplexMessagingIntegrationTest.java b/briar-android-tests/src/test/java/org/briarproject/sync/SimplexMessagingIntegrationTest.java
index 9ad9df0f2832ef25573aacb2b6e3c5158b9a3ed4..01f615511151b54caac2c6770873708ed38f6208 100644
--- a/briar-android-tests/src/test/java/org/briarproject/sync/SimplexMessagingIntegrationTest.java
+++ b/briar-android-tests/src/test/java/org/briarproject/sync/SimplexMessagingIntegrationTest.java
@@ -4,12 +4,10 @@ import org.briarproject.BriarTestCase;
 import org.briarproject.ImmediateExecutor;
 import org.briarproject.TestDatabaseModule;
 import org.briarproject.TestUtils;
-import org.briarproject.api.TransportId;
 import org.briarproject.api.contact.ContactId;
 import org.briarproject.api.contact.ContactManager;
 import org.briarproject.api.crypto.SecretKey;
 import org.briarproject.api.db.DatabaseComponent;
-import org.briarproject.api.db.Transaction;
 import org.briarproject.api.event.Event;
 import org.briarproject.api.event.EventBus;
 import org.briarproject.api.event.EventListener;
@@ -36,27 +34,26 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
-import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
-
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
 
-public class SimplexMessagingIntegrationTest extends BriarTestCase {
+import static org.briarproject.TestPluginsModule.MAX_LATENCY;
+import static org.briarproject.TestPluginsModule.TRANSPORT_ID;
+import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
+import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
-	private static final int MAX_LATENCY = 2 * 60 * 1000; // 2 minutes
+public class SimplexMessagingIntegrationTest extends BriarTestCase {
 
 	private final File testDir = TestUtils.getTestDirectory();
 	private final File aliceDir = new File(testDir, "alice");
 	private final File bobDir = new File(testDir, "bob");
-	private final TransportId transportId = new TransportId("id");
 	private final SecretKey master = TestUtils.createSecretKey();
 	private final long timestamp = System.currentTimeMillis();
 	private final AuthorId aliceId = new AuthorId(TestUtils.getRandomId());
@@ -80,7 +77,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
 
 	private byte[] write() throws Exception {
 		// Instantiate Alice's services
-		LifecycleManager lifecycleManager = alice.getLifeCycleManager();
+		LifecycleManager lifecycleManager = alice.getLifecycleManager();
 		DatabaseComponent db = alice.getDatabaseComponent();
 		IdentityManager identityManager = alice.getIdentityManager();
 		ContactManager contactManager = alice.getContactManager();
@@ -97,14 +94,6 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
 		// Start the lifecycle manager
 		lifecycleManager.startServices();
 		lifecycleManager.waitForStartup();
-		// Add a transport
-		Transaction txn = db.startTransaction();
-		try {
-			db.addTransport(txn, transportId, MAX_LATENCY);
-			txn.setComplete();
-		} finally {
-			db.endTransaction(txn);
-		}
 		// Add an identity for Alice
 		LocalAuthor aliceAuthor = new LocalAuthor(aliceId, "Alice",
 				new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp);
@@ -122,7 +111,8 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
 				groupId, timestamp, null, "text/plain", body);
 		messagingManager.addLocalMessage(message);
 		// Get a stream context
-		StreamContext ctx = keyManager.getStreamContext(contactId, transportId);
+		StreamContext ctx = keyManager.getStreamContext(contactId,
+				TRANSPORT_ID);
 		assertNotNull(ctx);
 		// Create a stream writer
 		ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -132,8 +122,8 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
 		PacketWriter packetWriter = packetWriterFactory.createPacketWriter(
 				streamWriter);
 		SyncSession session = new SimplexOutgoingSession(db,
-				new ImmediateExecutor(), eventBus, contactId, transportId,
-				MAX_LATENCY, packetWriter);
+				new ImmediateExecutor(), eventBus, contactId, MAX_LATENCY,
+				packetWriter);
 		// Write whatever needs to be written
 		session.run();
 		streamWriter.close();
@@ -148,7 +138,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
 
 	private void read(byte[] stream) throws Exception {
 		// Instantiate Bob's services
-		LifecycleManager lifecycleManager = bob.getLifeCycleManager();
+		LifecycleManager lifecycleManager = bob.getLifecycleManager();
 		DatabaseComponent db = bob.getDatabaseComponent();
 		IdentityManager identityManager = bob.getIdentityManager();
 		ContactManager contactManager = bob.getContactManager();
@@ -162,14 +152,6 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
 		// Start the lifecyle manager
 		lifecycleManager.startServices();
 		lifecycleManager.waitForStartup();
-		// Add a transport
-		Transaction txn = db.startTransaction();
-		try {
-			db.addTransport(txn, transportId, MAX_LATENCY);
-			txn.setComplete();
-		} finally {
-			db.endTransaction(txn);
-		}
 		// Add an identity for Bob
 		LocalAuthor bobAuthor = new LocalAuthor(bobId, "Bob",
 				new byte[MAX_PUBLIC_KEY_LENGTH], new byte[123], timestamp);
@@ -188,7 +170,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
 		byte[] tag = new byte[TAG_LENGTH];
 		int read = in.read(tag);
 		assertEquals(tag.length, read);
-		StreamContext ctx = keyManager.getStreamContext(transportId, tag);
+		StreamContext ctx = keyManager.getStreamContext(TRANSPORT_ID, tag);
 		assertNotNull(ctx);
 		// Create a stream reader
 		InputStream streamReader = streamReaderFactory.createStreamReader(
@@ -197,7 +179,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
 		PacketReader packetReader = packetReaderFactory.createPacketReader(
 				streamReader);
 		SyncSession session = new IncomingSession(db, new ImmediateExecutor(),
-				eventBus, contactId, transportId, packetReader);
+				eventBus, contactId, packetReader);
 		// No messages should have been added yet
 		assertFalse(listener.messageAdded);
 		// Read whatever needs to be read
diff --git a/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPluginFactory.java b/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPluginFactory.java
index 229aba22722481cbb67b91e49a1aa6fcd3c66d39..ee7acf26ba47c4fb39128f3eede571189c39e4f7 100644
--- a/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPluginFactory.java
+++ b/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothPluginFactory.java
@@ -2,8 +2,8 @@ package org.briarproject.plugins.droidtooth;
 
 import android.content.Context;
 
-import org.briarproject.api.TransportId;
 import org.briarproject.android.api.AndroidExecutor;
+import org.briarproject.api.TransportId;
 import org.briarproject.api.plugins.Backoff;
 import org.briarproject.api.plugins.BackoffFactory;
 import org.briarproject.api.plugins.duplex.DuplexPlugin;
@@ -40,6 +40,10 @@ public class DroidtoothPluginFactory implements DuplexPluginFactory {
 		return DroidtoothPlugin.ID;
 	}
 
+	public int getMaxLatency() {
+		return MAX_LATENCY;
+	}
+
 	public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
 		Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL,
 				MAX_POLLING_INTERVAL, BACKOFF_BASE);
diff --git a/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothTransportConnection.java b/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothTransportConnection.java
index dfb5b41f31e892a5d351f590e082b8591d79c761..e4db5673d219c82a65e44105c7e8f8f945a544fe 100644
--- a/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothTransportConnection.java
+++ b/briar-android/src/org/briarproject/plugins/droidtooth/DroidtoothTransportConnection.java
@@ -1,16 +1,16 @@
 package org.briarproject.plugins.droidtooth;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.concurrent.atomic.AtomicBoolean;
+import android.bluetooth.BluetoothSocket;
 
 import org.briarproject.api.plugins.Plugin;
 import org.briarproject.api.plugins.TransportConnectionReader;
 import org.briarproject.api.plugins.TransportConnectionWriter;
 import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
 
-import android.bluetooth.BluetoothSocket;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 class DroidtoothTransportConnection implements DuplexTransportConnection {
 
@@ -39,10 +39,6 @@ class DroidtoothTransportConnection implements DuplexTransportConnection {
 
 	private class Reader implements TransportConnectionReader {
 
-		public long getMaxLatency() {
-			return plugin.getMaxLatency();
-		}
-
 		public InputStream getInputStream() throws IOException {
 			return socket.getInputStream();
 		}
diff --git a/briar-android/src/org/briarproject/plugins/tcp/AndroidLanTcpPluginFactory.java b/briar-android/src/org/briarproject/plugins/tcp/AndroidLanTcpPluginFactory.java
index 0813ebfdd71dc460f9038f20ff314dcc749f50fd..16d456ad3b22e47a2e128e45afd55705dccba3dc 100644
--- a/briar-android/src/org/briarproject/plugins/tcp/AndroidLanTcpPluginFactory.java
+++ b/briar-android/src/org/briarproject/plugins/tcp/AndroidLanTcpPluginFactory.java
@@ -34,6 +34,10 @@ public class AndroidLanTcpPluginFactory implements DuplexPluginFactory {
 		return LanTcpPlugin.ID;
 	}
 
+	public int getMaxLatency() {
+		return MAX_LATENCY;
+	}
+
 	public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
 		Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL,
 				MAX_POLLING_INTERVAL, BACKOFF_BASE);
diff --git a/briar-android/src/org/briarproject/plugins/tor/TorPluginFactory.java b/briar-android/src/org/briarproject/plugins/tor/TorPluginFactory.java
index 3c6a749867b89366a086e6dfddf518e4337a76df..836dd48b61ff0aace079062dd32024d899762307 100644
--- a/briar-android/src/org/briarproject/plugins/tor/TorPluginFactory.java
+++ b/briar-android/src/org/briarproject/plugins/tor/TorPluginFactory.java
@@ -44,6 +44,10 @@ public class TorPluginFactory implements DuplexPluginFactory {
 		return TorPlugin.ID;
 	}
 
+	public int getMaxLatency() {
+		return MAX_LATENCY;
+	}
+
 	public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
 
 		// Check that we have a Tor binary for this architecture
diff --git a/briar-android/src/org/briarproject/plugins/tor/TorTransportConnection.java b/briar-android/src/org/briarproject/plugins/tor/TorTransportConnection.java
index a847bc912377c23cb44b3bdd0101650826695213..f6d806c880f8c859704a10ad0b71b5f7a13b32a6 100644
--- a/briar-android/src/org/briarproject/plugins/tor/TorTransportConnection.java
+++ b/briar-android/src/org/briarproject/plugins/tor/TorTransportConnection.java
@@ -1,16 +1,16 @@
 package org.briarproject.plugins.tor;
 
+import org.briarproject.api.plugins.Plugin;
+import org.briarproject.api.plugins.TransportConnectionReader;
+import org.briarproject.api.plugins.TransportConnectionWriter;
+import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.briarproject.api.plugins.Plugin;
-import org.briarproject.api.plugins.TransportConnectionReader;
-import org.briarproject.api.plugins.TransportConnectionWriter;
-import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
-
 class TorTransportConnection implements DuplexTransportConnection {
 
 	private final Plugin plugin;
@@ -38,10 +38,6 @@ class TorTransportConnection implements DuplexTransportConnection {
 
 	private class Reader implements TransportConnectionReader {
 
-		public long getMaxLatency() {
-			return plugin.getMaxLatency();
-		}
-
 		public InputStream getInputStream() throws IOException {
 			return socket.getInputStream();
 		}
diff --git a/briar-api/src/org/briarproject/api/db/DatabaseComponent.java b/briar-api/src/org/briarproject/api/db/DatabaseComponent.java
index 08bc9692f9a9f9d77f3d2dbe4724c7d1a539c35a..0b949758d8dcf83fb2ffce6bfa6122d6c705f30a 100644
--- a/briar-api/src/org/briarproject/api/db/DatabaseComponent.java
+++ b/briar-api/src/org/briarproject/api/db/DatabaseComponent.java
@@ -235,12 +235,6 @@ public interface DatabaseComponent {
 	Map<ContactId, TransportKeys> getTransportKeys(Transaction txn,
 			TransportId t) throws DbException;
 
-	/**
-	 * Returns the maximum latencies in milliseconds of all transports.
-	 */
-	Map<TransportId, Integer> getTransportLatencies(Transaction txn)
-			throws DbException;
-
 	/**
 	 * Increments the outgoing stream counter for the given contact and
 	 * transport in the given rotation period .
diff --git a/briar-api/src/org/briarproject/api/event/TransportAddedEvent.java b/briar-api/src/org/briarproject/api/event/TransportAddedEvent.java
deleted file mode 100644
index b775ce6c9e5dd88c112f6821fe157b4a0e68d853..0000000000000000000000000000000000000000
--- a/briar-api/src/org/briarproject/api/event/TransportAddedEvent.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.briarproject.api.event;
-
-import org.briarproject.api.TransportId;
-
-/** An event that is broadcast when a transport is added. */
-public class TransportAddedEvent extends Event {
-
-	private final TransportId transportId;
-	private final int maxLatency;
-
-	public TransportAddedEvent(TransportId transportId, int maxLatency) {
-		this.transportId = transportId;
-		this.maxLatency = maxLatency;
-	}
-
-	public TransportId getTransportId() {
-		return transportId;
-	}
-
-	public int getMaxLatency() {
-		return maxLatency;
-	}
-}
diff --git a/briar-api/src/org/briarproject/api/event/TransportRemovedEvent.java b/briar-api/src/org/briarproject/api/event/TransportRemovedEvent.java
deleted file mode 100644
index a0162d595e6a9705a5d8d4c03ee141cad4642284..0000000000000000000000000000000000000000
--- a/briar-api/src/org/briarproject/api/event/TransportRemovedEvent.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.briarproject.api.event;
-
-import org.briarproject.api.TransportId;
-
-/** An event that is broadcast when a transport is removed. */
-public class TransportRemovedEvent extends Event {
-
-	private final TransportId transportId;
-
-	public TransportRemovedEvent(TransportId transportId) {
-		this.transportId = transportId;
-	}
-
-	public TransportId getTransportId() {
-		return transportId;
-	}
-}
diff --git a/briar-api/src/org/briarproject/api/plugins/TransportConnectionReader.java b/briar-api/src/org/briarproject/api/plugins/TransportConnectionReader.java
index e071c4432b0b8d5eeccd0f014294b25281ed262a..e2b2855dea9bec5c5a764946f59c8ccbc256bd2f 100644
--- a/briar-api/src/org/briarproject/api/plugins/TransportConnectionReader.java
+++ b/briar-api/src/org/briarproject/api/plugins/TransportConnectionReader.java
@@ -9,10 +9,9 @@ import java.io.InputStream;
  */
 public interface TransportConnectionReader {
 
-	/** Returns the maximum latency of the transport in milliseconds. */
-	long getMaxLatency();
-
-	/** Returns an input stream for reading from the transport connection. */
+	/**
+	 * Returns an input stream for reading from the transport connection.
+	 */
 	InputStream getInputStream() throws IOException;
 
 	/**
@@ -20,10 +19,13 @@ public interface TransportConnectionReader {
 	 * simplex, the connection is closed. If the transport is duplex, the
 	 * connection is closed if <tt>exception</tt> is true or the other side of
 	 * the connection has been marked as closed.
-	 * @param exception true if the connection is being closed because of an
-	 * exception. This may affect how resources are disposed of.
+	 *
+	 * @param exception  true if the connection is being closed because of an
+	 *                   exception. This may affect how resources are disposed
+	 *                   of.
 	 * @param recognised true if the connection is definitely a Briar transport
-	 * connection. This may affect how resources are disposed of.
+	 *                   connection. This may affect how resources are disposed
+	 *                   of.
 	 */
 	void dispose(boolean exception, boolean recognised) throws IOException;
 }
diff --git a/briar-api/src/org/briarproject/api/plugins/duplex/DuplexPluginFactory.java b/briar-api/src/org/briarproject/api/plugins/duplex/DuplexPluginFactory.java
index 9e8cf7021759764dc4125e17e7f0b7e475b507fe..914402e3ca8f5666ee428a267bc2487d4260102a 100644
--- a/briar-api/src/org/briarproject/api/plugins/duplex/DuplexPluginFactory.java
+++ b/briar-api/src/org/briarproject/api/plugins/duplex/DuplexPluginFactory.java
@@ -2,12 +2,23 @@ package org.briarproject.api.plugins.duplex;
 
 import org.briarproject.api.TransportId;
 
-/** Factory for creating a plugin for a duplex transport. */
+/**
+ * Factory for creating a plugin for a duplex transport.
+ */
 public interface DuplexPluginFactory {
 
-	/** Returns the plugin's transport identifier. */
+	/**
+	 * Returns the plugin's transport identifier.
+	 */
 	TransportId getId();
 
-	/** Creates and returns a plugin, or null if no plugin can be created. */
+	/**
+	 * Returns the maximum latency of the transport in milliseconds.
+	 */
+	int getMaxLatency();
+
+	/**
+	 * Creates and returns a plugin, or null if no plugin can be created.
+	 */
 	DuplexPlugin createPlugin(DuplexPluginCallback callback);
 }
diff --git a/briar-api/src/org/briarproject/api/plugins/simplex/SimplexPluginFactory.java b/briar-api/src/org/briarproject/api/plugins/simplex/SimplexPluginFactory.java
index bc5c955a52114a8ba732751b2ad8a0cf126c5586..38277550abfdc61311b68ac1e7975e0a6aff748d 100644
--- a/briar-api/src/org/briarproject/api/plugins/simplex/SimplexPluginFactory.java
+++ b/briar-api/src/org/briarproject/api/plugins/simplex/SimplexPluginFactory.java
@@ -2,12 +2,23 @@ package org.briarproject.api.plugins.simplex;
 
 import org.briarproject.api.TransportId;
 
-/** Factory for creating a plugin for a simplex transport. */
+/**
+ * Factory for creating a plugin for a simplex transport.
+ */
 public interface SimplexPluginFactory {
 
-	/** Returns the plugin's transport identifier. */
+	/**
+	 * Returns the plugin's transport identifier.
+	 */
 	TransportId getId();
 
-	/** Creates and returns a plugin, or null if no plugin can be created. */
+	/**
+	 * Returns the maximum latency of the transport in milliseconds.
+	 */
+	int getMaxLatency();
+
+	/**
+	 * Creates and returns a plugin, or null if no plugin can be created.
+	 */
 	SimplexPlugin createPlugin(SimplexPluginCallback callback);
 }
diff --git a/briar-api/src/org/briarproject/api/sync/SyncSessionFactory.java b/briar-api/src/org/briarproject/api/sync/SyncSessionFactory.java
index b5db6a3493e9beba4af9ffcb9130325888de1c61..db5954ffedff642501d50301273972fc01521dd8 100644
--- a/briar-api/src/org/briarproject/api/sync/SyncSessionFactory.java
+++ b/briar-api/src/org/briarproject/api/sync/SyncSessionFactory.java
@@ -1,6 +1,5 @@
 package org.briarproject.api.sync;
 
-import org.briarproject.api.TransportId;
 import org.briarproject.api.contact.ContactId;
 
 import java.io.InputStream;
@@ -8,12 +7,11 @@ import java.io.OutputStream;
 
 public interface SyncSessionFactory {
 
-	SyncSession createIncomingSession(ContactId c, TransportId t,
-			InputStream in);
+	SyncSession createIncomingSession(ContactId c, InputStream in);
 
-	SyncSession createSimplexOutgoingSession(ContactId c, TransportId t,
-			int maxLatency, OutputStream out);
+	SyncSession createSimplexOutgoingSession(ContactId c, int maxLatency,
+			OutputStream out);
 
-	SyncSession createDuplexOutgoingSession(ContactId c, TransportId t,
-			int maxLatency, int maxIdleTime, OutputStream out);
+	SyncSession createDuplexOutgoingSession(ContactId c, int maxLatency,
+			int maxIdleTime, OutputStream out);
 }
diff --git a/briar-core/src/org/briarproject/db/Database.java b/briar-core/src/org/briarproject/db/Database.java
index 2544a96702e2b7b075cf55f4629b26c228e92dfe..6a642d74e4a2d11990d23929e55a40c1af899ed5 100644
--- a/briar-core/src/org/briarproject/db/Database.java
+++ b/briar-core/src/org/briarproject/db/Database.java
@@ -324,11 +324,6 @@ interface Database<T> {
 	Map<ContactId, TransportKeys> getTransportKeys(T txn, TransportId t)
 			throws DbException;
 
-	/**
-	 * Returns the maximum latencies in milliseconds of all transports.
-	 */
-	Map<TransportId, Integer> getTransportLatencies(T txn) throws DbException;
-
 	/**
 	 * Returns the IDs of all contacts to which the given group is visible.
 	 */
diff --git a/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java b/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java
index a912407513482683afdb1e4f97fd61d025b981c5..2178bf50ccc967769b7db57df338ede2ef7abba9 100644
--- a/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java
+++ b/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java
@@ -33,8 +33,6 @@ import org.briarproject.api.event.MessageValidatedEvent;
 import org.briarproject.api.event.MessagesAckedEvent;
 import org.briarproject.api.event.MessagesSentEvent;
 import org.briarproject.api.event.SettingsUpdatedEvent;
-import org.briarproject.api.event.TransportAddedEvent;
-import org.briarproject.api.event.TransportRemovedEvent;
 import org.briarproject.api.identity.Author;
 import org.briarproject.api.identity.AuthorId;
 import org.briarproject.api.identity.LocalAuthor;
@@ -192,10 +190,8 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
 	public void addTransport(Transaction transaction, TransportId t,
 			int maxLatency) throws DbException {
 		T txn = unbox(transaction);
-		if (!db.containsTransport(txn, t)) {
+		if (!db.containsTransport(txn, t))
 			db.addTransport(txn, t, maxLatency);
-			transaction.attach(new TransportAddedEvent(t, maxLatency));
-		}
 	}
 
 	public void addTransportKeys(Transaction transaction, ContactId c,
@@ -420,12 +416,6 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
 		return db.getTransportKeys(txn, t);
 	}
 
-	public Map<TransportId, Integer> getTransportLatencies(
-			Transaction transaction) throws DbException {
-		T txn = unbox(transaction);
-		return db.getTransportLatencies(txn);
-	}
-
 	public void incrementStreamCounter(Transaction transaction, ContactId c,
 			TransportId t, long rotationPeriod) throws DbException {
 		T txn = unbox(transaction);
@@ -579,7 +569,6 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
 		if (!db.containsTransport(txn, t))
 			throw new NoSuchTransportException();
 		db.removeTransport(txn, t);
-		transaction.attach(new TransportRemovedEvent(t));
 	}
 
 	public void setContactActive(Transaction transaction, ContactId c,
diff --git a/briar-core/src/org/briarproject/db/JdbcDatabase.java b/briar-core/src/org/briarproject/db/JdbcDatabase.java
index 7fc836348386c6aa042532889700060295bb69cc..536161562462bc9ce06144418701eb11d4b78510 100644
--- a/briar-core/src/org/briarproject/db/JdbcDatabase.java
+++ b/briar-core/src/org/briarproject/db/JdbcDatabase.java
@@ -1542,30 +1542,6 @@ abstract class JdbcDatabase implements Database<Connection> {
 		}
 	}
 
-	public Map<TransportId, Integer> getTransportLatencies(Connection txn)
-			throws DbException {
-		PreparedStatement ps = null;
-		ResultSet rs = null;
-		try {
-			String sql = "SELECT transportId, maxLatency FROM transports";
-			ps = txn.prepareStatement(sql);
-			rs = ps.executeQuery();
-			Map<TransportId, Integer> latencies =
-					new HashMap<TransportId, Integer>();
-			while (rs.next()) {
-				TransportId id = new TransportId(rs.getString(1));
-				latencies.put(id, rs.getInt(2));
-			}
-			rs.close();
-			ps.close();
-			return Collections.unmodifiableMap(latencies);
-		} catch (SQLException e) {
-			tryToClose(rs);
-			tryToClose(ps);
-			throw new DbException(e);
-		}
-	}
-
 	public Collection<ContactId> getVisibility(Connection txn, GroupId g)
 			throws DbException {
 		PreparedStatement ps = null;
diff --git a/briar-core/src/org/briarproject/lifecycle/LifecycleManagerImpl.java b/briar-core/src/org/briarproject/lifecycle/LifecycleManagerImpl.java
index aba60f16b147645e738cda56f258a17d73766c8c..f153a3a37714ca1ae8c7935fa12c2d9d950138ea 100644
--- a/briar-core/src/org/briarproject/lifecycle/LifecycleManagerImpl.java
+++ b/briar-core/src/org/briarproject/lifecycle/LifecycleManagerImpl.java
@@ -6,7 +6,6 @@ import org.briarproject.api.event.EventBus;
 import org.briarproject.api.event.ShutdownEvent;
 import org.briarproject.api.lifecycle.LifecycleManager;
 import org.briarproject.api.lifecycle.Service;
-import org.briarproject.api.system.Clock;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -30,7 +29,6 @@ class LifecycleManagerImpl implements LifecycleManager {
 	private static final Logger LOG =
 			Logger.getLogger(LifecycleManagerImpl.class.getName());
 
-	private final Clock clock;
 	private final DatabaseComponent db;
 	private final EventBus eventBus;
 	private final Collection<Service> services;
@@ -41,8 +39,7 @@ class LifecycleManagerImpl implements LifecycleManager {
 	private final CountDownLatch shutdownLatch = new CountDownLatch(1);
 
 	@Inject
-	LifecycleManagerImpl(Clock clock, DatabaseComponent db, EventBus eventBus) {
-		this.clock = clock;
+	LifecycleManagerImpl(DatabaseComponent db, EventBus eventBus) {
 		this.db = db;
 		this.eventBus = eventBus;
 		services = new CopyOnWriteArrayList<Service>();
@@ -68,9 +65,9 @@ class LifecycleManagerImpl implements LifecycleManager {
 		}
 		try {
 			LOG.info("Starting services");
-			long now = clock.currentTimeMillis();
+			long start = System.currentTimeMillis();
 			boolean reopened = db.open();
-			long duration = clock.currentTimeMillis() - now;
+			long duration = System.currentTimeMillis() - start;
 			if (LOG.isLoggable(INFO)) {
 				if (reopened)
 					LOG.info("Reopening database took " + duration + " ms");
@@ -78,9 +75,9 @@ class LifecycleManagerImpl implements LifecycleManager {
 			}
 			dbLatch.countDown();
 			for (Service s : services) {
-				now = clock.currentTimeMillis();
+				start = System.currentTimeMillis();
 				boolean started = s.start();
-				duration = clock.currentTimeMillis() - now;
+				duration = System.currentTimeMillis() - start;
 				if (!started) {
 					if (LOG.isLoggable(WARNING)) {
 						String name = s.getClass().getName();
diff --git a/briar-core/src/org/briarproject/lifecycle/LifecycleModule.java b/briar-core/src/org/briarproject/lifecycle/LifecycleModule.java
index 7b98244eb405d4e30dc32a4fe1de56e01251d8a6..7ad4cb6b0cb27f48c5e8a6fa6253ed0ee3176c07 100644
--- a/briar-core/src/org/briarproject/lifecycle/LifecycleModule.java
+++ b/briar-core/src/org/briarproject/lifecycle/LifecycleModule.java
@@ -1,6 +1,10 @@
 package org.briarproject.lifecycle;
 
-import static java.util.concurrent.TimeUnit.SECONDS;
+import org.briarproject.api.db.DatabaseComponent;
+import org.briarproject.api.event.EventBus;
+import org.briarproject.api.lifecycle.IoExecutor;
+import org.briarproject.api.lifecycle.LifecycleManager;
+import org.briarproject.api.lifecycle.ShutdownManager;
 
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.Executor;
@@ -12,16 +16,11 @@ import java.util.concurrent.ThreadPoolExecutor;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 
-import org.briarproject.api.db.DatabaseComponent;
-import org.briarproject.api.event.EventBus;
-import org.briarproject.api.lifecycle.IoExecutor;
-import org.briarproject.api.lifecycle.LifecycleManager;
-import org.briarproject.api.lifecycle.ShutdownManager;
-import org.briarproject.api.system.Clock;
-
 import dagger.Module;
 import dagger.Provides;
 
+import static java.util.concurrent.TimeUnit.SECONDS;
+
 @Module
 public class LifecycleModule {
 
@@ -51,9 +50,9 @@ public class LifecycleModule {
 
 	@Provides
 	@Singleton
-	LifecycleManager provideLifeCycleManager(Clock clock, DatabaseComponent db,
+	LifecycleManager provideLifecycleManager(DatabaseComponent db,
 			EventBus eventBus) {
-		return new LifecycleManagerImpl(clock, db, eventBus);
+		return new LifecycleManagerImpl(db, eventBus);
 	}
 
 	@Provides
@@ -63,5 +62,4 @@ public class LifecycleModule {
 		lifecycleManager.registerForShutdown(ioExecutor);
 		return ioExecutor;
 	}
-
 }
diff --git a/briar-core/src/org/briarproject/plugins/ConnectionManagerImpl.java b/briar-core/src/org/briarproject/plugins/ConnectionManagerImpl.java
index 0b6fe073d310186b53c0fac4208846407e85d707..1ccc15e014cbbc87001f4ee4114c25070c7f87eb 100644
--- a/briar-core/src/org/briarproject/plugins/ConnectionManagerImpl.java
+++ b/briar-core/src/org/briarproject/plugins/ConnectionManagerImpl.java
@@ -90,8 +90,8 @@ class ConnectionManagerImpl implements ConnectionManager {
 			TransportConnectionReader r) throws IOException {
 		InputStream streamReader = streamReaderFactory.createStreamReader(
 				r.getInputStream(), ctx);
-		return syncSessionFactory.createIncomingSession(
-				ctx.getContactId(), ctx.getTransportId(), streamReader);
+		return syncSessionFactory.createIncomingSession(ctx.getContactId(),
+				streamReader);
 	}
 
 	private SyncSession createSimplexOutgoingSession(StreamContext ctx,
@@ -99,8 +99,7 @@ class ConnectionManagerImpl implements ConnectionManager {
 		OutputStream streamWriter = streamWriterFactory.createStreamWriter(
 				w.getOutputStream(), ctx);
 		return syncSessionFactory.createSimplexOutgoingSession(
-				ctx.getContactId(), ctx.getTransportId(), w.getMaxLatency(),
-				streamWriter);
+				ctx.getContactId(), w.getMaxLatency(), streamWriter);
 	}
 
 	private SyncSession createDuplexOutgoingSession(StreamContext ctx,
@@ -108,8 +107,8 @@ class ConnectionManagerImpl implements ConnectionManager {
 		OutputStream streamWriter = streamWriterFactory.createStreamWriter(
 				w.getOutputStream(), ctx);
 		return syncSessionFactory.createDuplexOutgoingSession(
-				ctx.getContactId(), ctx.getTransportId(), w.getMaxLatency(),
-				w.getMaxIdleTime(), streamWriter);
+				ctx.getContactId(), w.getMaxLatency(), w.getMaxIdleTime(),
+				streamWriter);
 	}
 
 	private class ManageIncomingSimplexConnection implements Runnable {
diff --git a/briar-core/src/org/briarproject/plugins/PluginManagerImpl.java b/briar-core/src/org/briarproject/plugins/PluginManagerImpl.java
index 85aa73e080287c319bd4e123fc3cd14926e4b2e0..367b1b66c5be99be31d6e20c930f5702bab09893 100644
--- a/briar-core/src/org/briarproject/plugins/PluginManagerImpl.java
+++ b/briar-core/src/org/briarproject/plugins/PluginManagerImpl.java
@@ -2,9 +2,7 @@ package org.briarproject.plugins;
 
 import org.briarproject.api.TransportId;
 import org.briarproject.api.contact.ContactId;
-import org.briarproject.api.db.DatabaseComponent;
 import org.briarproject.api.db.DbException;
-import org.briarproject.api.db.Transaction;
 import org.briarproject.api.event.EventBus;
 import org.briarproject.api.event.TransportDisabledEvent;
 import org.briarproject.api.event.TransportEnabledEvent;
@@ -28,7 +26,6 @@ import org.briarproject.api.properties.TransportProperties;
 import org.briarproject.api.properties.TransportPropertyManager;
 import org.briarproject.api.settings.Settings;
 import org.briarproject.api.settings.SettingsManager;
-import org.briarproject.api.system.Clock;
 import org.briarproject.api.ui.UiCallback;
 
 import java.io.IOException;
@@ -56,8 +53,6 @@ class PluginManagerImpl implements PluginManager, Service {
 	private final Executor ioExecutor;
 	private final EventBus eventBus;
 	private final PluginConfig pluginConfig;
-	private final Clock clock;
-	private final DatabaseComponent db;
 	private final Poller poller;
 	private final ConnectionManager connectionManager;
 	private final SettingsManager settingsManager;
@@ -69,8 +64,7 @@ class PluginManagerImpl implements PluginManager, Service {
 
 	@Inject
 	PluginManagerImpl(@IoExecutor Executor ioExecutor, EventBus eventBus,
-			PluginConfig pluginConfig, Clock clock,
-			DatabaseComponent db, Poller poller,
+			PluginConfig pluginConfig, Poller poller,
 			ConnectionManager connectionManager,
 			SettingsManager settingsManager,
 			TransportPropertyManager transportPropertyManager,
@@ -78,8 +72,6 @@ class PluginManagerImpl implements PluginManager, Service {
 		this.ioExecutor = ioExecutor;
 		this.eventBus = eventBus;
 		this.pluginConfig = pluginConfig;
-		this.clock = clock;
-		this.db = db;
 		this.poller = poller;
 		this.connectionManager = connectionManager;
 		this.settingsManager = settingsManager;
@@ -181,26 +173,9 @@ class PluginManagerImpl implements PluginManager, Service {
 					return;
 				}
 				try {
-					long start = clock.currentTimeMillis();
-					Transaction txn = db.startTransaction();
-					try {
-						db.addTransport(txn, id, plugin.getMaxLatency());
-						txn.setComplete();
-					} finally {
-						db.endTransaction(txn);
-					}
-					long duration = clock.currentTimeMillis() - start;
-					if (LOG.isLoggable(INFO))
-						LOG.info("Adding transport took " + duration + " ms");
-				} catch (DbException e) {
-					if (LOG.isLoggable(WARNING))
-						LOG.log(WARNING, e.toString(), e);
-					return;
-				}
-				try {
-					long start = clock.currentTimeMillis();
+					long start = System.currentTimeMillis();
 					boolean started = plugin.start();
-					long duration = clock.currentTimeMillis() - start;
+					long duration = System.currentTimeMillis() - start;
 					if (started) {
 						plugins.put(id, plugin);
 						simplexPlugins.add(plugin);
@@ -250,26 +225,9 @@ class PluginManagerImpl implements PluginManager, Service {
 					return;
 				}
 				try {
-					long start = clock.currentTimeMillis();
-					Transaction txn = db.startTransaction();
-					try {
-						db.addTransport(txn, id, plugin.getMaxLatency());
-						txn.setComplete();
-					} finally {
-						db.endTransaction(txn);
-					}
-					long duration = clock.currentTimeMillis() - start;
-					if (LOG.isLoggable(INFO))
-						LOG.info("Adding transport took " + duration + " ms");
-				} catch (DbException e) {
-					if (LOG.isLoggable(WARNING))
-						LOG.log(WARNING, e.toString(), e);
-					return;
-				}
-				try {
-					long start = clock.currentTimeMillis();
+					long start = System.currentTimeMillis();
 					boolean started = plugin.start();
-					long duration = clock.currentTimeMillis() - start;
+					long duration = System.currentTimeMillis() - start;
 					if (started) {
 						plugins.put(id, plugin);
 						duplexPlugins.add(plugin);
@@ -307,9 +265,9 @@ class PluginManagerImpl implements PluginManager, Service {
 
 		public void run() {
 			try {
-				long start = clock.currentTimeMillis();
+				long start = System.currentTimeMillis();
 				plugin.stop();
-				long duration = clock.currentTimeMillis() - start;
+				long duration = System.currentTimeMillis() - start;
 				if (LOG.isLoggable(INFO)) {
 					String name = plugin.getClass().getSimpleName();
 					LOG.info("Stopping " + name + " took " + duration + " ms");
diff --git a/briar-core/src/org/briarproject/plugins/PluginsModule.java b/briar-core/src/org/briarproject/plugins/PluginsModule.java
index 6f3357b8b5ac88229644c4a6eae3e38c7f283477..d106d8920f549b308a30006094e01818ec8e1313 100644
--- a/briar-core/src/org/briarproject/plugins/PluginsModule.java
+++ b/briar-core/src/org/briarproject/plugins/PluginsModule.java
@@ -1,8 +1,5 @@
 package org.briarproject.plugins;
 
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
 import org.briarproject.api.event.EventBus;
 import org.briarproject.api.lifecycle.IoExecutor;
 import org.briarproject.api.lifecycle.LifecycleManager;
@@ -19,10 +16,12 @@ import org.briarproject.api.transport.StreamWriterFactory;
 import java.security.SecureRandom;
 import java.util.concurrent.Executor;
 
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
 import dagger.Module;
 import dagger.Provides;
 
-
 @Module
 public class PluginsModule {
 
@@ -45,8 +44,8 @@ public class PluginsModule {
 
 	@Provides
 	ConnectionManager provideConnectionManager(
-			@IoExecutor Executor ioExecutor,
-			KeyManager keyManager, StreamReaderFactory streamReaderFactory,
+			@IoExecutor Executor ioExecutor, KeyManager keyManager,
+			StreamReaderFactory streamReaderFactory,
 			StreamWriterFactory streamWriterFactory,
 			SyncSessionFactory syncSessionFactory,
 			ConnectionRegistry connectionRegistry) {
@@ -61,7 +60,6 @@ public class PluginsModule {
 		return new ConnectionRegistryImpl(eventBus);
 	}
 
-
 	@Provides
 	@Singleton
 	PluginManager getPluginManager(LifecycleManager lifecycleManager,
@@ -69,5 +67,4 @@ public class PluginsModule {
 		lifecycleManager.register(pluginManager);
 		return pluginManager;
 	}
-
 }
diff --git a/briar-core/src/org/briarproject/plugins/file/FileTransportReader.java b/briar-core/src/org/briarproject/plugins/file/FileTransportReader.java
index 39ea14b3eab4bcc3c477bf7b1a0222fb42403244..ed6219797c7dd5d33629eee3bb25f79955a708bd 100644
--- a/briar-core/src/org/briarproject/plugins/file/FileTransportReader.java
+++ b/briar-core/src/org/briarproject/plugins/file/FileTransportReader.java
@@ -1,13 +1,13 @@
 package org.briarproject.plugins.file;
 
-import static java.util.logging.Level.WARNING;
+import org.briarproject.api.plugins.TransportConnectionReader;
 
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.logging.Logger;
 
-import org.briarproject.api.plugins.TransportConnectionReader;
+import static java.util.logging.Level.WARNING;
 
 class FileTransportReader implements TransportConnectionReader {
 
@@ -24,10 +24,6 @@ class FileTransportReader implements TransportConnectionReader {
 		this.plugin = plugin;
 	}
 
-	public long getMaxLatency() {
-		return plugin.getMaxLatency();
-	}
-
 	public InputStream getInputStream() {
 		return in;
 	}
diff --git a/briar-core/src/org/briarproject/plugins/tcp/LanTcpPluginFactory.java b/briar-core/src/org/briarproject/plugins/tcp/LanTcpPluginFactory.java
index 929f63a6b849b80454e24c33f7783cdd765b0c5f..9b354427a240b81f05bb54aadade681ccdf3727b 100644
--- a/briar-core/src/org/briarproject/plugins/tcp/LanTcpPluginFactory.java
+++ b/briar-core/src/org/briarproject/plugins/tcp/LanTcpPluginFactory.java
@@ -30,6 +30,10 @@ public class LanTcpPluginFactory implements DuplexPluginFactory {
 		return LanTcpPlugin.ID;
 	}
 
+	public int getMaxLatency() {
+		return MAX_LATENCY;
+	}
+
 	public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
 		Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL,
 				MAX_POLLING_INTERVAL, BACKOFF_BASE);
diff --git a/briar-core/src/org/briarproject/plugins/tcp/TcpTransportConnection.java b/briar-core/src/org/briarproject/plugins/tcp/TcpTransportConnection.java
index 213cb88ce5d1cf81c5075089d691d8d23bf90e33..c400975bf3d44bb21ba87d97b174a7e292b728ac 100644
--- a/briar-core/src/org/briarproject/plugins/tcp/TcpTransportConnection.java
+++ b/briar-core/src/org/briarproject/plugins/tcp/TcpTransportConnection.java
@@ -1,16 +1,16 @@
 package org.briarproject.plugins.tcp;
 
+import org.briarproject.api.plugins.Plugin;
+import org.briarproject.api.plugins.TransportConnectionReader;
+import org.briarproject.api.plugins.TransportConnectionWriter;
+import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.briarproject.api.plugins.Plugin;
-import org.briarproject.api.plugins.TransportConnectionReader;
-import org.briarproject.api.plugins.TransportConnectionWriter;
-import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
-
 class TcpTransportConnection implements DuplexTransportConnection {
 
 	private final Plugin plugin;
@@ -38,10 +38,6 @@ class TcpTransportConnection implements DuplexTransportConnection {
 
 	private class Reader implements TransportConnectionReader {
 
-		public long getMaxLatency() {
-			return plugin.getMaxLatency();
-		}
-
 		public InputStream getInputStream() throws IOException {
 			return socket.getInputStream();
 		}
diff --git a/briar-core/src/org/briarproject/plugins/tcp/WanTcpPluginFactory.java b/briar-core/src/org/briarproject/plugins/tcp/WanTcpPluginFactory.java
index 659b79f1c0536b80105ea855caf6a63e6a3b48a1..44fdf5edfdf1ffe9b7b4c60c04678f6002dd6d4f 100644
--- a/briar-core/src/org/briarproject/plugins/tcp/WanTcpPluginFactory.java
+++ b/briar-core/src/org/briarproject/plugins/tcp/WanTcpPluginFactory.java
@@ -33,6 +33,10 @@ public class WanTcpPluginFactory implements DuplexPluginFactory {
 		return WanTcpPlugin.ID;
 	}
 
+	public int getMaxLatency() {
+		return MAX_LATENCY;
+	}
+
 	public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
 		Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL,
 				MAX_POLLING_INTERVAL, BACKOFF_BASE);
diff --git a/briar-core/src/org/briarproject/sync/DuplexOutgoingSession.java b/briar-core/src/org/briarproject/sync/DuplexOutgoingSession.java
index 8976eb7d16be1f951098999468f57a810740341c..f9a6726d54ad0d428944c21eb63acddb8cbb5ecf 100644
--- a/briar-core/src/org/briarproject/sync/DuplexOutgoingSession.java
+++ b/briar-core/src/org/briarproject/sync/DuplexOutgoingSession.java
@@ -1,6 +1,5 @@
 package org.briarproject.sync;
 
-import org.briarproject.api.TransportId;
 import org.briarproject.api.contact.ContactId;
 import org.briarproject.api.db.DatabaseComponent;
 import org.briarproject.api.db.DbException;
@@ -15,7 +14,6 @@ import org.briarproject.api.event.MessageSharedEvent;
 import org.briarproject.api.event.MessageToAckEvent;
 import org.briarproject.api.event.MessageToRequestEvent;
 import org.briarproject.api.event.ShutdownEvent;
-import org.briarproject.api.event.TransportRemovedEvent;
 import org.briarproject.api.sync.Ack;
 import org.briarproject.api.sync.Offer;
 import org.briarproject.api.sync.PacketWriter;
@@ -59,7 +57,6 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
 	private final EventBus eventBus;
 	private final Clock clock;
 	private final ContactId contactId;
-	private final TransportId transportId;
 	private final int maxLatency, maxIdleTime;
 	private final PacketWriter packetWriter;
 	private final BlockingQueue<ThrowingRunnable<IOException>> writerTasks;
@@ -67,15 +64,13 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
 	private volatile boolean interrupted = false;
 
 	DuplexOutgoingSession(DatabaseComponent db, Executor dbExecutor,
-			EventBus eventBus, Clock clock, ContactId contactId,
-			TransportId transportId, int maxLatency, int maxIdleTime,
-			PacketWriter packetWriter) {
+			EventBus eventBus, Clock clock, ContactId contactId, int maxLatency,
+			int maxIdleTime, PacketWriter packetWriter) {
 		this.db = db;
 		this.dbExecutor = dbExecutor;
 		this.eventBus = eventBus;
 		this.clock = clock;
 		this.contactId = contactId;
-		this.transportId = transportId;
 		this.maxLatency = maxLatency;
 		this.maxIdleTime = maxIdleTime;
 		this.packetWriter = packetWriter;
@@ -167,9 +162,6 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
 				dbExecutor.execute(new GenerateRequest());
 		} else if (e instanceof ShutdownEvent) {
 			interrupt();
-		} else if (e instanceof TransportRemovedEvent) {
-			TransportRemovedEvent t = (TransportRemovedEvent) e;
-			if (t.getTransportId().equals(transportId)) interrupt();
 		}
 	}
 
diff --git a/briar-core/src/org/briarproject/sync/IncomingSession.java b/briar-core/src/org/briarproject/sync/IncomingSession.java
index 5e5f4c6df220bcfb23ef55b6417d07eb8f79ed65..970afbf8b084d009fa8083df988ef5cff4a7485d 100644
--- a/briar-core/src/org/briarproject/sync/IncomingSession.java
+++ b/briar-core/src/org/briarproject/sync/IncomingSession.java
@@ -1,7 +1,6 @@
 package org.briarproject.sync;
 
 import org.briarproject.api.FormatException;
-import org.briarproject.api.TransportId;
 import org.briarproject.api.contact.ContactId;
 import org.briarproject.api.db.DatabaseComponent;
 import org.briarproject.api.db.DbException;
@@ -11,7 +10,6 @@ import org.briarproject.api.event.Event;
 import org.briarproject.api.event.EventBus;
 import org.briarproject.api.event.EventListener;
 import org.briarproject.api.event.ShutdownEvent;
-import org.briarproject.api.event.TransportRemovedEvent;
 import org.briarproject.api.sync.Ack;
 import org.briarproject.api.sync.Message;
 import org.briarproject.api.sync.Offer;
@@ -37,19 +35,17 @@ class IncomingSession implements SyncSession, EventListener {
 	private final Executor dbExecutor;
 	private final EventBus eventBus;
 	private final ContactId contactId;
-	private final TransportId transportId;
 	private final PacketReader packetReader;
 
 	private volatile boolean interrupted = false;
 
 	IncomingSession(DatabaseComponent db, Executor dbExecutor,
-			EventBus eventBus, ContactId contactId, TransportId transportId,
+			EventBus eventBus, ContactId contactId,
 			PacketReader packetReader) {
 		this.db = db;
 		this.dbExecutor = dbExecutor;
 		this.eventBus = eventBus;
 		this.contactId = contactId;
-		this.transportId = transportId;
 		this.packetReader = packetReader;
 	}
 
@@ -90,9 +86,6 @@ class IncomingSession implements SyncSession, EventListener {
 			if (c.getContactId().equals(contactId)) interrupt();
 		} else if (e instanceof ShutdownEvent) {
 			interrupt();
-		} else if (e instanceof TransportRemovedEvent) {
-			TransportRemovedEvent t = (TransportRemovedEvent) e;
-			if (t.getTransportId().equals(transportId)) interrupt();
 		}
 	}
 
diff --git a/briar-core/src/org/briarproject/sync/SimplexOutgoingSession.java b/briar-core/src/org/briarproject/sync/SimplexOutgoingSession.java
index 31ca6268485c4f18b2de9f1c469e1a579287120d..d69b8eb81eea73edb33e030cadd602ddf37d4454 100644
--- a/briar-core/src/org/briarproject/sync/SimplexOutgoingSession.java
+++ b/briar-core/src/org/briarproject/sync/SimplexOutgoingSession.java
@@ -1,6 +1,5 @@
 package org.briarproject.sync;
 
-import org.briarproject.api.TransportId;
 import org.briarproject.api.contact.ContactId;
 import org.briarproject.api.db.DatabaseComponent;
 import org.briarproject.api.db.DbException;
@@ -10,7 +9,6 @@ import org.briarproject.api.event.Event;
 import org.briarproject.api.event.EventBus;
 import org.briarproject.api.event.EventListener;
 import org.briarproject.api.event.ShutdownEvent;
-import org.briarproject.api.event.TransportRemovedEvent;
 import org.briarproject.api.sync.Ack;
 import org.briarproject.api.sync.PacketWriter;
 import org.briarproject.api.sync.SyncSession;
@@ -48,7 +46,6 @@ class SimplexOutgoingSession implements SyncSession, EventListener {
 	private final Executor dbExecutor;
 	private final EventBus eventBus;
 	private final ContactId contactId;
-	private final TransportId transportId;
 	private final int maxLatency;
 	private final PacketWriter packetWriter;
 	private final AtomicInteger outstandingQueries;
@@ -57,13 +54,12 @@ class SimplexOutgoingSession implements SyncSession, EventListener {
 	private volatile boolean interrupted = false;
 
 	SimplexOutgoingSession(DatabaseComponent db, Executor dbExecutor,
-			EventBus eventBus, ContactId contactId, TransportId transportId,
+			EventBus eventBus, ContactId contactId,
 			int maxLatency, PacketWriter packetWriter) {
 		this.db = db;
 		this.dbExecutor = dbExecutor;
 		this.eventBus = eventBus;
 		this.contactId = contactId;
-		this.transportId = transportId;
 		this.maxLatency = maxLatency;
 		this.packetWriter = packetWriter;
 		outstandingQueries = new AtomicInteger(2); // One per type of packet
@@ -108,9 +104,6 @@ class SimplexOutgoingSession implements SyncSession, EventListener {
 			if (c.getContactId().equals(contactId)) interrupt();
 		} else if (e instanceof ShutdownEvent) {
 			interrupt();
-		} else if (e instanceof TransportRemovedEvent) {
-			TransportRemovedEvent t = (TransportRemovedEvent) e;
-			if (t.getTransportId().equals(transportId)) interrupt();
 		}
 	}
 
diff --git a/briar-core/src/org/briarproject/sync/SyncSessionFactoryImpl.java b/briar-core/src/org/briarproject/sync/SyncSessionFactoryImpl.java
index 5a4021b1d41ba409a1bc2394edbcad0dc0043f24..6fac0012f6acfcad59e8790844d9a6fa06523d4c 100644
--- a/briar-core/src/org/briarproject/sync/SyncSessionFactoryImpl.java
+++ b/briar-core/src/org/briarproject/sync/SyncSessionFactoryImpl.java
@@ -1,6 +1,5 @@
 package org.briarproject.sync;
 
-import org.briarproject.api.TransportId;
 import org.briarproject.api.contact.ContactId;
 import org.briarproject.api.db.DatabaseComponent;
 import org.briarproject.api.db.DatabaseExecutor;
@@ -41,24 +40,22 @@ class SyncSessionFactoryImpl implements SyncSessionFactory {
 		this.packetWriterFactory = packetWriterFactory;
 	}
 
-	public SyncSession createIncomingSession(ContactId c, TransportId t,
-			InputStream in) {
+	public SyncSession createIncomingSession(ContactId c, InputStream in) {
 		PacketReader packetReader = packetReaderFactory.createPacketReader(in);
-		return new IncomingSession(db, dbExecutor, eventBus, c, t,
-				packetReader);
+		return new IncomingSession(db, dbExecutor, eventBus, c, packetReader);
 	}
 
-	public SyncSession createSimplexOutgoingSession(ContactId c, TransportId t,
+	public SyncSession createSimplexOutgoingSession(ContactId c,
 			int maxLatency, OutputStream out) {
 		PacketWriter packetWriter = packetWriterFactory.createPacketWriter(out);
-		return new SimplexOutgoingSession(db, dbExecutor, eventBus, c, t,
+		return new SimplexOutgoingSession(db, dbExecutor, eventBus, c,
 				maxLatency, packetWriter);
 	}
 
-	public SyncSession createDuplexOutgoingSession(ContactId c, TransportId t,
-			int maxLatency, int maxIdleTime, OutputStream out) {
+	public SyncSession createDuplexOutgoingSession(ContactId c, int maxLatency,
+			int maxIdleTime, OutputStream out) {
 		PacketWriter packetWriter = packetWriterFactory.createPacketWriter(out);
-		return new DuplexOutgoingSession(db, dbExecutor, eventBus, clock, c, t,
+		return new DuplexOutgoingSession(db, dbExecutor, eventBus, clock, c,
 				maxLatency, maxIdleTime, packetWriter);
 	}
 }
diff --git a/briar-core/src/org/briarproject/transport/KeyManagerImpl.java b/briar-core/src/org/briarproject/transport/KeyManagerImpl.java
index 3cbfef824f96f241b75389fab118ab25114c9731..276daf453a91c8e8bb616a8f15391cde6d0e96cc 100644
--- a/briar-core/src/org/briarproject/transport/KeyManagerImpl.java
+++ b/briar-core/src/org/briarproject/transport/KeyManagerImpl.java
@@ -13,15 +13,17 @@ import org.briarproject.api.event.ContactRemovedEvent;
 import org.briarproject.api.event.ContactStatusChangedEvent;
 import org.briarproject.api.event.Event;
 import org.briarproject.api.event.EventListener;
-import org.briarproject.api.event.TransportAddedEvent;
-import org.briarproject.api.event.TransportRemovedEvent;
 import org.briarproject.api.lifecycle.Service;
+import org.briarproject.api.plugins.PluginConfig;
+import org.briarproject.api.plugins.duplex.DuplexPluginFactory;
+import org.briarproject.api.plugins.simplex.SimplexPluginFactory;
 import org.briarproject.api.system.Clock;
 import org.briarproject.api.system.Timer;
 import org.briarproject.api.transport.KeyManager;
 import org.briarproject.api.transport.StreamContext;
 
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
@@ -40,6 +42,7 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
 	private final DatabaseComponent db;
 	private final CryptoComponent crypto;
 	private final ExecutorService dbExecutor;
+	private final PluginConfig pluginConfig;
 	private final Timer timer;
 	private final Clock clock;
 	private final Map<ContactId, Boolean> activeContacts;
@@ -47,11 +50,12 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
 
 	@Inject
 	KeyManagerImpl(DatabaseComponent db, CryptoComponent crypto,
-			@DatabaseExecutor ExecutorService dbExecutor, Timer timer,
-			Clock clock) {
+			@DatabaseExecutor ExecutorService dbExecutor,
+			PluginConfig pluginConfig, Timer timer, Clock clock) {
 		this.db = db;
 		this.crypto = crypto;
 		this.dbExecutor = dbExecutor;
+		this.pluginConfig = pluginConfig;
 		this.timer = timer;
 		this.clock = clock;
 		// Use a ConcurrentHashMap as a thread-safe set
@@ -61,21 +65,31 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
 
 	@Override
 	public boolean start() {
+		Map<TransportId, Integer> latencies =
+				new HashMap<TransportId, Integer>();
+		for (SimplexPluginFactory f : pluginConfig.getSimplexFactories())
+			latencies.put(f.getId(), f.getMaxLatency());
+		for (DuplexPluginFactory f : pluginConfig.getDuplexFactories())
+			latencies.put(f.getId(), f.getMaxLatency());
 		try {
 			Collection<Contact> contacts;
-			Map<TransportId, Integer> latencies;
 			Transaction txn = db.startTransaction();
 			try {
 				contacts = db.getContacts(txn);
-				latencies = db.getTransportLatencies(txn);
+				for (Entry<TransportId, Integer> e : latencies.entrySet())
+					db.addTransport(txn, e.getKey(), e.getValue());
 				txn.setComplete();
 			} finally {
 				db.endTransaction(txn);
 			}
 			for (Contact c : contacts)
 				if (c.isActive()) activeContacts.put(c.getId(), true);
-			for (Entry<TransportId, Integer> e : latencies.entrySet())
-				addTransport(e.getKey(), e.getValue());
+			for (Entry<TransportId, Integer> e : latencies.entrySet()) {
+				TransportKeyManager m = new TransportKeyManager(db, crypto,
+						timer, clock, e.getKey(), e.getValue());
+				managers.put(e.getKey(), m);
+				m.start();
+			}
 		} catch (DbException e) {
 			if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
 			return false;
@@ -125,12 +139,7 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
 	}
 
 	public void eventOccurred(Event e) {
-		if (e instanceof TransportAddedEvent) {
-			TransportAddedEvent t = (TransportAddedEvent) e;
-			addTransport(t.getTransportId(), t.getMaxLatency());
-		} else if (e instanceof TransportRemovedEvent) {
-			removeTransport(((TransportRemovedEvent) e).getTransportId());
-		} else if (e instanceof ContactRemovedEvent) {
+		if (e instanceof ContactRemovedEvent) {
 			removeContact(((ContactRemovedEvent) e).getContactId());
 		} else if (e instanceof ContactStatusChangedEvent) {
 			ContactStatusChangedEvent c = (ContactStatusChangedEvent) e;
@@ -139,21 +148,6 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
 		}
 	}
 
-	private void addTransport(final TransportId t, final int maxLatency) {
-		dbExecutor.execute(new Runnable() {
-			public void run() {
-				TransportKeyManager m = new TransportKeyManager(db, crypto,
-						timer, clock, t, maxLatency);
-				// Don't add transport twice if event is received during startup
-				if (managers.putIfAbsent(t, m) == null) m.start();
-			}
-		});
-	}
-
-	private void removeTransport(TransportId t) {
-		managers.remove(t);
-	}
-
 	private void removeContact(final ContactId c) {
 		activeContacts.remove(c);
 		dbExecutor.execute(new Runnable() {
diff --git a/briar-desktop/src/org/briarproject/lifecycle/DesktopLifecycleModule.java b/briar-desktop/src/org/briarproject/lifecycle/DesktopLifecycleModule.java
index 4986668b1e5f25af228994f5c0f14824c391bfaa..79525935a0123371418ae744006f41563c3b2394 100644
--- a/briar-desktop/src/org/briarproject/lifecycle/DesktopLifecycleModule.java
+++ b/briar-desktop/src/org/briarproject/lifecycle/DesktopLifecycleModule.java
@@ -1,10 +1,6 @@
 package org.briarproject.lifecycle;
 
-import org.briarproject.api.db.DatabaseComponent;
-import org.briarproject.api.event.EventBus;
-import org.briarproject.api.lifecycle.LifecycleManager;
 import org.briarproject.api.lifecycle.ShutdownManager;
-import org.briarproject.api.system.Clock;
 import org.briarproject.util.OsUtils;
 
 import javax.inject.Singleton;
@@ -15,22 +11,10 @@ import dagger.Provides;
 @Module
 public class DesktopLifecycleModule extends LifecycleModule {
 
-	@Provides
-	@Singleton
-	LifecycleManager provideLifecycleManager(Clock clock, DatabaseComponent db,
-			EventBus eventBus) {
-		return new LifecycleManagerImpl(clock, db, eventBus);
-	}
-
 	@Provides
 	@Singleton
 	ShutdownManager provideDesktopShutdownManager() {
-		if (OsUtils.isWindows()) {
-			return new WindowsShutdownManagerImpl();
-		}
-		else {
-			return new ShutdownManagerImpl();
-		}
+		if (OsUtils.isWindows()) return new WindowsShutdownManagerImpl();
+		else return new ShutdownManagerImpl();
 	}
-
 }
diff --git a/briar-desktop/src/org/briarproject/plugins/bluetooth/BluetoothPluginFactory.java b/briar-desktop/src/org/briarproject/plugins/bluetooth/BluetoothPluginFactory.java
index 2d7f156e22d861f777808cc98ba0fbbb69224d13..d4165bc410fbbe3ba5f6a1ff71e55a388bf8945d 100644
--- a/briar-desktop/src/org/briarproject/plugins/bluetooth/BluetoothPluginFactory.java
+++ b/briar-desktop/src/org/briarproject/plugins/bluetooth/BluetoothPluginFactory.java
@@ -32,6 +32,10 @@ public class BluetoothPluginFactory implements DuplexPluginFactory {
 		return BluetoothPlugin.ID;
 	}
 
+	public int getMaxLatency() {
+		return MAX_LATENCY;
+	}
+
 	public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
 		Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL,
 				MAX_POLLING_INTERVAL, BACKOFF_BASE);
diff --git a/briar-desktop/src/org/briarproject/plugins/bluetooth/BluetoothTransportConnection.java b/briar-desktop/src/org/briarproject/plugins/bluetooth/BluetoothTransportConnection.java
index 8f852f1ef820c87244e36f2f8b15df4f96a33e03..6139b8c14bba8b749537ed1e6533526cfaee6113 100644
--- a/briar-desktop/src/org/briarproject/plugins/bluetooth/BluetoothTransportConnection.java
+++ b/briar-desktop/src/org/briarproject/plugins/bluetooth/BluetoothTransportConnection.java
@@ -1,5 +1,10 @@
 package org.briarproject.plugins.bluetooth;
 
+import org.briarproject.api.plugins.Plugin;
+import org.briarproject.api.plugins.TransportConnectionReader;
+import org.briarproject.api.plugins.TransportConnectionWriter;
+import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -7,11 +12,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.microedition.io.StreamConnection;
 
-import org.briarproject.api.plugins.Plugin;
-import org.briarproject.api.plugins.TransportConnectionReader;
-import org.briarproject.api.plugins.TransportConnectionWriter;
-import org.briarproject.api.plugins.duplex.DuplexTransportConnection;
-
 class BluetoothTransportConnection implements DuplexTransportConnection {
 
 	private final Plugin plugin;
@@ -39,10 +39,6 @@ class BluetoothTransportConnection implements DuplexTransportConnection {
 
 	private class Reader implements TransportConnectionReader {
 
-		public long getMaxLatency() {
-			return plugin.getMaxLatency();
-		}
-
 		public InputStream getInputStream() throws IOException {
 			return stream.openInputStream();
 		}
diff --git a/briar-desktop/src/org/briarproject/plugins/file/RemovableDrivePluginFactory.java b/briar-desktop/src/org/briarproject/plugins/file/RemovableDrivePluginFactory.java
index f4ed1e348121584b22dcbc8f6ac21f693045608a..e2db0717d77aafdeade20519f45dbe55e8afb840 100644
--- a/briar-desktop/src/org/briarproject/plugins/file/RemovableDrivePluginFactory.java
+++ b/briar-desktop/src/org/briarproject/plugins/file/RemovableDrivePluginFactory.java
@@ -24,6 +24,10 @@ public class RemovableDrivePluginFactory implements SimplexPluginFactory {
 		return RemovableDrivePlugin.ID;
 	}
 
+	public int getMaxLatency() {
+		return MAX_LATENCY;
+	}
+
 	public SimplexPlugin createPlugin(SimplexPluginCallback callback) {
 		RemovableDriveFinder finder;
 		RemovableDriveMonitor monitor;
diff --git a/briar-desktop/src/org/briarproject/plugins/modem/ModemPlugin.java b/briar-desktop/src/org/briarproject/plugins/modem/ModemPlugin.java
index 954529a5e8221fa1341f7b0a7b198409e33efa19..ffa06c2a477689045735b9c1aa5cd28ebd04ae07 100644
--- a/briar-desktop/src/org/briarproject/plugins/modem/ModemPlugin.java
+++ b/briar-desktop/src/org/briarproject/plugins/modem/ModemPlugin.java
@@ -194,10 +194,6 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
 
 		private class Reader implements TransportConnectionReader {
 
-			public long getMaxLatency() {
-				return ModemPlugin.this.getMaxLatency();
-			}
-
 			public InputStream getInputStream() throws IOException {
 				return modem.getInputStream();
 			}
diff --git a/briar-desktop/src/org/briarproject/plugins/modem/ModemPluginFactory.java b/briar-desktop/src/org/briarproject/plugins/modem/ModemPluginFactory.java
index 2e9561c077fa55e332c7fd4d9d24de706aed6ba0..690b3c7d78f6f603a400bd690a1c92464b263215 100644
--- a/briar-desktop/src/org/briarproject/plugins/modem/ModemPluginFactory.java
+++ b/briar-desktop/src/org/briarproject/plugins/modem/ModemPluginFactory.java
@@ -1,7 +1,5 @@
 package org.briarproject.plugins.modem;
 
-import java.util.concurrent.Executor;
-
 import org.briarproject.api.TransportId;
 import org.briarproject.api.plugins.duplex.DuplexPlugin;
 import org.briarproject.api.plugins.duplex.DuplexPluginCallback;
@@ -9,6 +7,8 @@ import org.briarproject.api.plugins.duplex.DuplexPluginFactory;
 import org.briarproject.api.reliability.ReliabilityLayerFactory;
 import org.briarproject.util.StringUtils;
 
+import java.util.concurrent.Executor;
+
 public class ModemPluginFactory implements DuplexPluginFactory {
 
 	private static final int MAX_LATENCY = 30 * 1000; // 30 seconds
@@ -26,6 +26,10 @@ public class ModemPluginFactory implements DuplexPluginFactory {
 		return ModemPlugin.ID;
 	}
 
+	public int getMaxLatency() {
+		return MAX_LATENCY;
+	}
+
 	public DuplexPlugin createPlugin(DuplexPluginCallback callback) {
 		// This plugin is not enabled by default
 		String enabled = callback.getSettings().get("enabled");
diff --git a/briar-tests/src/org/briarproject/TestPluginsModule.java b/briar-tests/src/org/briarproject/TestPluginsModule.java
new file mode 100644
index 0000000000000000000000000000000000000000..b7cf4209ee34199b051b1bc2e61c95d308291c43
--- /dev/null
+++ b/briar-tests/src/org/briarproject/TestPluginsModule.java
@@ -0,0 +1,55 @@
+package org.briarproject;
+
+import org.briarproject.api.TransportId;
+import org.briarproject.api.plugins.PluginConfig;
+import org.briarproject.api.plugins.duplex.DuplexPluginFactory;
+import org.briarproject.api.plugins.simplex.SimplexPlugin;
+import org.briarproject.api.plugins.simplex.SimplexPluginCallback;
+import org.briarproject.api.plugins.simplex.SimplexPluginFactory;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import dagger.Module;
+import dagger.Provides;
+
+@Module
+public class TestPluginsModule {
+
+	public static final TransportId TRANSPORT_ID = new TransportId("id");
+	public static final int MAX_LATENCY = 2 * 60 * 1000; // 2 minutes
+
+	private final SimplexPluginFactory simplex = new SimplexPluginFactory() {
+
+		@Override
+		public TransportId getId() {
+			return TRANSPORT_ID;
+		}
+
+		@Override
+		public int getMaxLatency() {
+			return MAX_LATENCY;
+		}
+
+		@Override
+		public SimplexPlugin createPlugin(SimplexPluginCallback callback) {
+			return null;
+		}
+	};
+
+	@Provides
+	PluginConfig providePluginConfig() {
+		return new PluginConfig() {
+
+			@Override
+			public Collection<DuplexPluginFactory> getDuplexFactories() {
+				return Collections.emptyList();
+			}
+
+			@Override
+			public Collection<SimplexPluginFactory> getSimplexFactories() {
+				return Collections.singletonList(simplex);
+			}
+		};
+	}
+}
diff --git a/briar-tests/src/org/briarproject/plugins/PluginManagerImplTest.java b/briar-tests/src/org/briarproject/plugins/PluginManagerImplTest.java
index e6efbc5e54ebe8ffad38f487432842db20d8f719..2d2ea5ce2ce61e9547d46b7fa15e1f0bdb08e8b7 100644
--- a/briar-tests/src/org/briarproject/plugins/PluginManagerImplTest.java
+++ b/briar-tests/src/org/briarproject/plugins/PluginManagerImplTest.java
@@ -2,8 +2,6 @@ package org.briarproject.plugins;
 
 import org.briarproject.BriarTestCase;
 import org.briarproject.api.TransportId;
-import org.briarproject.api.db.DatabaseComponent;
-import org.briarproject.api.db.Transaction;
 import org.briarproject.api.event.EventBus;
 import org.briarproject.api.plugins.ConnectionManager;
 import org.briarproject.api.plugins.PluginConfig;
@@ -15,9 +13,7 @@ import org.briarproject.api.plugins.simplex.SimplexPluginCallback;
 import org.briarproject.api.plugins.simplex.SimplexPluginFactory;
 import org.briarproject.api.properties.TransportPropertyManager;
 import org.briarproject.api.settings.SettingsManager;
-import org.briarproject.api.system.Clock;
 import org.briarproject.api.ui.UiCallback;
-import org.briarproject.system.SystemClock;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
 import org.jmock.lib.concurrent.Synchroniser;
@@ -33,14 +29,12 @@ public class PluginManagerImplTest extends BriarTestCase {
 
 	@Test
 	public void testStartAndStop() throws Exception {
-		Clock clock = new SystemClock();
 		Mockery context = new Mockery() {{
 			setThreadingPolicy(new Synchroniser());
 		}};
 		final Executor ioExecutor = Executors.newSingleThreadExecutor();
 		final EventBus eventBus = context.mock(EventBus.class);
 		final PluginConfig pluginConfig = context.mock(PluginConfig.class);
-		final DatabaseComponent db = context.mock(DatabaseComponent.class);
 		final Poller poller = context.mock(Poller.class);
 		final ConnectionManager connectionManager =
 				context.mock(ConnectionManager.class);
@@ -49,30 +43,27 @@ public class PluginManagerImplTest extends BriarTestCase {
 		final TransportPropertyManager transportPropertyManager =
 				context.mock(TransportPropertyManager.class);
 		final UiCallback uiCallback = context.mock(UiCallback.class);
+
 		// Two simplex plugin factories: both create plugins, one fails to start
 		final SimplexPluginFactory simplexFactory =
 				context.mock(SimplexPluginFactory.class);
 		final SimplexPlugin simplexPlugin = context.mock(SimplexPlugin.class);
 		final TransportId simplexId = new TransportId("simplex");
-		final int simplexLatency = 12345;
-		final Transaction simplexTxn = new Transaction(null);
 		final SimplexPluginFactory simplexFailFactory =
 				context.mock(SimplexPluginFactory.class, "simplexFailFactory");
 		final SimplexPlugin simplexFailPlugin =
 				context.mock(SimplexPlugin.class, "simplexFailPlugin");
 		final TransportId simplexFailId = new TransportId("simplex1");
-		final int simplexFailLatency = 23456;
-		final Transaction simplexFailTxn = new Transaction(null);
+
 		// Two duplex plugin factories: one creates a plugin, the other fails
 		final DuplexPluginFactory duplexFactory =
 				context.mock(DuplexPluginFactory.class);
 		final DuplexPlugin duplexPlugin = context.mock(DuplexPlugin.class);
 		final TransportId duplexId = new TransportId("duplex");
-		final int duplexLatency = 34567;
-		final Transaction duplexTxn = new Transaction(null);
 		final DuplexPluginFactory duplexFailFactory =
 				context.mock(DuplexPluginFactory.class, "duplexFailFactory");
 		final TransportId duplexFailId = new TransportId("duplex1");
+
 		context.checking(new Expectations() {{
 			// First simplex plugin
 			oneOf(pluginConfig).getSimplexFactories();
@@ -83,12 +74,6 @@ public class PluginManagerImplTest extends BriarTestCase {
 			oneOf(simplexFactory).createPlugin(with(any(
 					SimplexPluginCallback.class)));
 			will(returnValue(simplexPlugin)); // Created
-			oneOf(simplexPlugin).getMaxLatency();
-			will(returnValue(simplexLatency));
-			oneOf(db).startTransaction();
-			will(returnValue(simplexTxn));
-			oneOf(db).addTransport(simplexTxn, simplexId, simplexLatency);
-			oneOf(db).endTransaction(simplexTxn);
 			oneOf(simplexPlugin).start();
 			will(returnValue(true)); // Started
 			oneOf(simplexPlugin).shouldPoll();
@@ -100,13 +85,6 @@ public class PluginManagerImplTest extends BriarTestCase {
 			oneOf(simplexFailFactory).createPlugin(with(any(
 					SimplexPluginCallback.class)));
 			will(returnValue(simplexFailPlugin)); // Created
-			oneOf(simplexFailPlugin).getMaxLatency();
-			will(returnValue(simplexFailLatency));
-			oneOf(db).startTransaction();
-			will(returnValue(simplexFailTxn));
-			oneOf(db).addTransport(simplexFailTxn, simplexFailId,
-					simplexFailLatency);
-			oneOf(db).endTransaction(simplexFailTxn);
 			oneOf(simplexFailPlugin).start();
 			will(returnValue(false)); // Failed to start
 			// First duplex plugin
@@ -117,12 +95,6 @@ public class PluginManagerImplTest extends BriarTestCase {
 			oneOf(duplexFactory).createPlugin(with(any(
 					DuplexPluginCallback.class)));
 			will(returnValue(duplexPlugin)); // Created
-			oneOf(duplexPlugin).getMaxLatency();
-			will(returnValue(duplexLatency));
-			oneOf(db).startTransaction();
-			will(returnValue(duplexTxn));
-			oneOf(db).addTransport(duplexTxn, duplexId, duplexLatency);
-			oneOf(db).endTransaction(duplexTxn);
 			oneOf(duplexPlugin).start();
 			will(returnValue(true)); // Started
 			oneOf(duplexPlugin).shouldPoll();
@@ -139,13 +111,15 @@ public class PluginManagerImplTest extends BriarTestCase {
 			oneOf(simplexPlugin).stop();
 			oneOf(duplexPlugin).stop();
 		}});
+
 		PluginManagerImpl p = new PluginManagerImpl(ioExecutor, eventBus,
-				pluginConfig, clock, db, poller, connectionManager,
-				settingsManager, transportPropertyManager, uiCallback);
+				pluginConfig, poller, connectionManager, settingsManager,
+				transportPropertyManager, uiCallback);
 
 		// Two plugins should be started and stopped
 		assertTrue(p.start());
 		assertTrue(p.stop());
+
 		context.assertIsSatisfied();
 	}
 }
diff --git a/briar-tests/src/org/briarproject/sync/SimplexOutgoingSessionTest.java b/briar-tests/src/org/briarproject/sync/SimplexOutgoingSessionTest.java
index a62b7add1271d904c284c2af23d5313448a9a824..c71df9982e3109cca195bcc508a31f543ae0e101 100644
--- a/briar-tests/src/org/briarproject/sync/SimplexOutgoingSessionTest.java
+++ b/briar-tests/src/org/briarproject/sync/SimplexOutgoingSessionTest.java
@@ -3,7 +3,6 @@ package org.briarproject.sync;
 import org.briarproject.BriarTestCase;
 import org.briarproject.ImmediateExecutor;
 import org.briarproject.TestUtils;
-import org.briarproject.api.TransportId;
 import org.briarproject.api.contact.ContactId;
 import org.briarproject.api.db.DatabaseComponent;
 import org.briarproject.api.db.Transaction;
@@ -28,7 +27,6 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
 	private final Executor dbExecutor;
 	private final EventBus eventBus;
 	private final ContactId contactId;
-	private final TransportId transportId;
 	private final MessageId messageId;
 	private final int maxLatency;
 	private final PacketWriter packetWriter;
@@ -40,7 +38,6 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
 		eventBus = context.mock(EventBus.class);
 		packetWriter = context.mock(PacketWriter.class);
 		contactId = new ContactId(234);
-		transportId = new TransportId("id");
 		messageId = new MessageId(TestUtils.getRandomId());
 		maxLatency = Integer.MAX_VALUE;
 	}
@@ -48,10 +45,10 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
 	@Test
 	public void testNothingToSend() throws Exception {
 		final SimplexOutgoingSession session = new SimplexOutgoingSession(db,
-				dbExecutor, eventBus, contactId, transportId, maxLatency,
-				packetWriter);
+				dbExecutor, eventBus, contactId, maxLatency, packetWriter);
 		final Transaction noAckTxn = new Transaction(null);
 		final Transaction noMsgTxn = new Transaction(null);
+
 		context.checking(new Expectations() {{
 			// Add listener
 			oneOf(eventBus).addListener(session);
@@ -73,7 +70,9 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
 			// Remove listener
 			oneOf(eventBus).removeListener(session);
 		}});
+
 		session.run();
+
 		context.assertIsSatisfied();
 	}
 
@@ -82,12 +81,12 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
 		final Ack ack = new Ack(Collections.singletonList(messageId));
 		final byte[] raw = new byte[1234];
 		final SimplexOutgoingSession session = new SimplexOutgoingSession(db,
-				dbExecutor, eventBus, contactId, transportId, maxLatency,
-				packetWriter);
+				dbExecutor, eventBus, contactId, maxLatency, packetWriter);
 		final Transaction ackTxn = new Transaction(null);
 		final Transaction noAckTxn = new Transaction(null);
 		final Transaction msgTxn = new Transaction(null);
 		final Transaction noMsgTxn = new Transaction(null);
+
 		context.checking(new Expectations() {{
 			// Add listener
 			oneOf(eventBus).addListener(session);
@@ -124,7 +123,9 @@ public class SimplexOutgoingSessionTest extends BriarTestCase {
 			// Remove listener
 			oneOf(eventBus).removeListener(session);
 		}});
+
 		session.run();
+
 		context.assertIsSatisfied();
 	}
 }