diff --git a/Cargo.lock b/Cargo.lock
index 9682f2fee9d1978db4795e6fe499b8fab872a1f0..8b25b4784c2b2193f1aaee80379195e40856c844 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1516,12 +1516,6 @@ dependencies = [
  "winapi",
 ]
 
-[[package]]
-name = "paste"
-version = "1.0.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58"
-
 [[package]]
 name = "pear"
 version = "0.2.3"
@@ -1990,7 +1984,7 @@ dependencies = [
 [[package]]
 name = "ruma"
 version = "0.4.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "assign",
  "js_int",
@@ -2011,7 +2005,7 @@ dependencies = [
 [[package]]
 name = "ruma-api"
 version = "0.18.5"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "bytes",
  "http",
@@ -2027,7 +2021,7 @@ dependencies = [
 [[package]]
 name = "ruma-api-macros"
 version = "0.18.5"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "proc-macro-crate",
  "proc-macro2",
@@ -2038,7 +2032,7 @@ dependencies = [
 [[package]]
 name = "ruma-appservice-api"
 version = "0.4.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "ruma-api",
  "ruma-common",
@@ -2052,7 +2046,7 @@ dependencies = [
 [[package]]
 name = "ruma-client-api"
 version = "0.12.3"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "assign",
  "bytes",
@@ -2072,7 +2066,7 @@ dependencies = [
 [[package]]
 name = "ruma-common"
 version = "0.6.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "indexmap",
  "js_int",
@@ -2087,7 +2081,7 @@ dependencies = [
 [[package]]
 name = "ruma-events"
 version = "0.24.6"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "indoc",
  "js_int",
@@ -2103,7 +2097,7 @@ dependencies = [
 [[package]]
 name = "ruma-events-macros"
 version = "0.24.6"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "proc-macro-crate",
  "proc-macro2",
@@ -2114,7 +2108,7 @@ dependencies = [
 [[package]]
 name = "ruma-federation-api"
 version = "0.3.1"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "js_int",
  "ruma-api",
@@ -2129,9 +2123,8 @@ dependencies = [
 [[package]]
 name = "ruma-identifiers"
 version = "0.20.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
- "paste",
  "percent-encoding",
  "rand 0.8.4",
  "ruma-identifiers-macros",
@@ -2144,7 +2137,7 @@ dependencies = [
 [[package]]
 name = "ruma-identifiers-macros"
 version = "0.20.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "quote",
  "ruma-identifiers-validation",
@@ -2154,7 +2147,7 @@ dependencies = [
 [[package]]
 name = "ruma-identifiers-validation"
 version = "0.5.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "thiserror",
 ]
@@ -2162,7 +2155,7 @@ dependencies = [
 [[package]]
 name = "ruma-identity-service-api"
 version = "0.3.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "js_int",
  "ruma-api",
@@ -2175,7 +2168,7 @@ dependencies = [
 [[package]]
 name = "ruma-push-gateway-api"
 version = "0.3.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "js_int",
  "ruma-api",
@@ -2190,7 +2183,7 @@ dependencies = [
 [[package]]
 name = "ruma-serde"
 version = "0.5.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "bytes",
  "form_urlencoded",
@@ -2204,7 +2197,7 @@ dependencies = [
 [[package]]
 name = "ruma-serde-macros"
 version = "0.5.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "proc-macro-crate",
  "proc-macro2",
@@ -2215,7 +2208,7 @@ dependencies = [
 [[package]]
 name = "ruma-signatures"
 version = "0.9.0"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "base64 0.13.0",
  "ed25519-dalek",
@@ -2232,7 +2225,7 @@ dependencies = [
 [[package]]
 name = "ruma-state-res"
 version = "0.4.1"
-source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
+source = "git+https://github.com/ruma/ruma?rev=bba7d624425da2c65a834bbd0e633b7577488cdf#bba7d624425da2c65a834bbd0e633b7577488cdf"
 dependencies = [
  "itertools 0.10.1",
  "js_int",
diff --git a/Cargo.toml b/Cargo.toml
index 91c7e259592b6fe49b1b82a7c74d11f8ba614202..b24afb5c91bd485cca934a83b47ddc5703aefd39 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,7 +19,7 @@ rocket = { version = "0.5.0-rc.1", features = ["tls"] } # Used to handle request
 
 # Used for matrix spec type definitions and helpers
 #ruma = { version = "0.4.0", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
-ruma = { git = "https://github.com/ruma/ruma", rev = "e7f01ca55a1eff437bad754bf0554cc09f44ec2a", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
+ruma = { git = "https://github.com/ruma/ruma", rev = "bba7d624425da2c65a834bbd0e633b7577488cdf", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
 #ruma = { git = "https://github.com/timokoesters/ruma", rev = "50c1db7e0a3a21fc794b0cce3b64285a4c750c71", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
 #ruma = { path = "../ruma/crates/ruma", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
 
diff --git a/src/client_server/account.rs b/src/client_server/account.rs
index 4b3ad0d4a933b9e374bf22f4e45903207e4f896a..d7c2f63e099296c345eae4fd714b8acb5242fd93 100644
--- a/src/client_server/account.rs
+++ b/src/client_server/account.rs
@@ -11,10 +11,9 @@
         error::ErrorKind,
         r0::{
             account::{
-                change_password, deactivate, get_username_availability, register, whoami,
-                ThirdPartyIdRemovalStatus,
+                change_password, deactivate, get_3pids, get_username_availability, register,
+                whoami, ThirdPartyIdRemovalStatus,
             },
-            contact::get_contacts,
             uiaa::{AuthFlow, AuthType, UiaaInfo},
         },
     },
@@ -282,7 +281,7 @@ pub async fn register_route(
         let mut content = RoomCreateEventContent::new(conduit_user.clone());
         content.federate = true;
         content.predecessor = None;
-        content.room_version = RoomVersionId::Version6;
+        content.room_version = RoomVersionId::V6;
 
         // 1. The room create event
         db.rooms.build_and_append_pdu(
@@ -433,7 +432,7 @@ pub async fn register_route(
         )?;
 
         // Room alias
-        let alias: RoomAliasId = format!("#admins:{}", db.globals.server_name())
+        let alias: Box<RoomAliasId> = format!("#admins:{}", db.globals.server_name())
             .try_into()
             .expect("#admins:server_name is a valid alias name");
 
@@ -757,9 +756,9 @@ pub async fn deactivate_route(
     get("/_matrix/client/r0/account/3pid", data = "<body>")
 )]
 pub async fn third_party_route(
-    body: Ruma<get_contacts::Request>,
-) -> ConduitResult<get_contacts::Response> {
+    body: Ruma<get_3pids::Request>,
+) -> ConduitResult<get_3pids::Response> {
     let _sender_user = body.sender_user.as_ref().expect("user is authenticated");
 
-    Ok(get_contacts::Response::new(Vec::new()).into())
+    Ok(get_3pids::Response::new(Vec::new()).into())
 }
diff --git a/src/client_server/capabilities.rs b/src/client_server/capabilities.rs
index f86b23b5d8762d3c70ff75e405076aaec86dcf12..c69b7cb2349aad14b2a0b0cb8dd965d96e30011f 100644
--- a/src/client_server/capabilities.rs
+++ b/src/client_server/capabilities.rs
@@ -22,12 +22,12 @@ pub async fn get_capabilities_route(
     _body: Ruma<get_capabilities::Request>,
 ) -> ConduitResult<get_capabilities::Response> {
     let mut available = BTreeMap::new();
-    available.insert(RoomVersionId::Version5, RoomVersionStability::Stable);
-    available.insert(RoomVersionId::Version6, RoomVersionStability::Stable);
+    available.insert(RoomVersionId::V5, RoomVersionStability::Stable);
+    available.insert(RoomVersionId::V6, RoomVersionStability::Stable);
 
     let mut capabilities = Capabilities::new();
     capabilities.room_versions = RoomVersionsCapability {
-        default: RoomVersionId::Version6,
+        default: RoomVersionId::V6,
         available,
     };
 
diff --git a/src/client_server/directory.rs b/src/client_server/directory.rs
index 490f7524c3ab9524a7927e989bad5255670f6104..5a1bc4948fa0cb3f401188e2977d9037426906a1 100644
--- a/src/client_server/directory.rs
+++ b/src/client_server/directory.rs
@@ -167,7 +167,7 @@ pub(crate) async fn get_public_rooms_filtered_helper(
                 other_server,
                 federation::directory::get_public_rooms_filtered::v1::Request {
                     limit,
-                    since: since.as_deref(),
+                    since,
                     filter: Filter {
                         generic_search_term: filter.generic_search_term.as_deref(),
                     },
diff --git a/src/client_server/keys.rs b/src/client_server/keys.rs
index a44f5e9c3286b831b842d6e80cfc7cb9b52d9b0c..08ea6e76fe2b23f63b766957ad407d9b0b83a4c2 100644
--- a/src/client_server/keys.rs
+++ b/src/client_server/keys.rs
@@ -316,7 +316,7 @@ pub async fn get_key_changes_route(
 
 pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
     sender_user: Option<&UserId>,
-    device_keys_input: &BTreeMap<UserId, Vec<Box<DeviceId>>>,
+    device_keys_input: &BTreeMap<Box<UserId>, Vec<Box<DeviceId>>>,
     allowed_signatures: F,
     db: &Database,
 ) -> Result<get_keys::Response> {
@@ -328,6 +328,8 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
     let mut get_over_federation = HashMap::new();
 
     for (user_id, device_ids) in device_keys_input {
+        let user_id: &UserId = &**user_id;
+
         if user_id.server_name() != db.globals.server_name() {
             get_over_federation
                 .entry(user_id.server_name())
@@ -355,11 +357,11 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
                     container.insert(device_id, keys);
                 }
             }
-            device_keys.insert(user_id.clone(), container);
+            device_keys.insert(user_id.to_owned(), container);
         } else {
             for device_id in device_ids {
                 let mut container = BTreeMap::new();
-                if let Some(mut keys) = db.users.get_device_keys(&user_id.clone(), device_id)? {
+                if let Some(mut keys) = db.users.get_device_keys(user_id, device_id)? {
                     let metadata = db.users.get_device_metadata(user_id, device_id)?.ok_or(
                         Error::BadRequest(
                             ErrorKind::InvalidParam,
@@ -371,24 +373,24 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
                         device_display_name: metadata.display_name,
                     };
 
-                    container.insert(device_id.clone(), keys);
+                    container.insert(device_id.to_owned(), keys);
                 }
-                device_keys.insert(user_id.clone(), container);
+                device_keys.insert(user_id.to_owned(), container);
             }
         }
 
         if let Some(master_key) = db.users.get_master_key(user_id, &allowed_signatures)? {
-            master_keys.insert(user_id.clone(), master_key);
+            master_keys.insert(user_id.to_owned(), master_key);
         }
         if let Some(self_signing_key) = db
             .users
             .get_self_signing_key(user_id, &allowed_signatures)?
         {
-            self_signing_keys.insert(user_id.clone(), self_signing_key);
+            self_signing_keys.insert(user_id.to_owned(), self_signing_key);
         }
         if Some(user_id) == sender_user {
             if let Some(user_signing_key) = db.users.get_user_signing_key(user_id)? {
-                user_signing_keys.insert(user_id.clone(), user_signing_key);
+                user_signing_keys.insert(user_id.to_owned(), user_signing_key);
             }
         }
     }
@@ -400,7 +402,7 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
         .map(|(server, vec)| async move {
             let mut device_keys_input_fed = BTreeMap::new();
             for (user_id, keys) in vec {
-                device_keys_input_fed.insert(user_id.clone(), keys.clone());
+                device_keys_input_fed.insert(user_id.to_owned(), keys.clone());
             }
             (
                 server,
@@ -440,7 +442,7 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
 }
 
 pub(crate) async fn claim_keys_helper(
-    one_time_keys_input: &BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>,
+    one_time_keys_input: &BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>,
     db: &Database,
 ) -> Result<claim_keys::Response> {
     let mut one_time_keys = BTreeMap::new();
diff --git a/src/client_server/membership.rs b/src/client_server/membership.rs
index ec685ec9d378e3d408a8718f38259dfe0d1a36ac..f65287dabeb2ac95185c5b3f5374068f61f4514c 100644
--- a/src/client_server/membership.rs
+++ b/src/client_server/membership.rs
@@ -64,7 +64,7 @@ pub async fn join_room_by_id_route(
         .filter_map(|event| serde_json::from_str(event.json().get()).ok())
         .filter_map(|event: serde_json::Value| event.get("sender").cloned())
         .filter_map(|sender| sender.as_str().map(|s| s.to_owned()))
-        .filter_map(|sender| UserId::try_from(sender).ok())
+        .filter_map(|sender| Box::<UserId>::try_from(sender).ok())
         .map(|user| user.server_name().to_owned())
         .collect();
 
@@ -72,7 +72,7 @@ pub async fn join_room_by_id_route(
 
     let ret = join_room_by_id_helper(
         &db,
-        body.sender_user.as_ref(),
+        body.sender_user.as_deref(),
         &body.room_id,
         &servers,
         body.third_party_signed.as_ref(),
@@ -101,7 +101,7 @@ pub async fn join_room_by_id_or_alias_route(
 ) -> ConduitResult<join_room_by_id_or_alias::Response> {
     let sender_user = body.sender_user.as_ref().expect("user is authenticated");
 
-    let (servers, room_id) = match RoomId::try_from(body.room_id_or_alias.clone()) {
+    let (servers, room_id) = match Box::<RoomId>::try_from(body.room_id_or_alias.clone()) {
         Ok(room_id) => {
             let mut servers: HashSet<_> = db
                 .rooms
@@ -111,7 +111,7 @@ pub async fn join_room_by_id_or_alias_route(
                 .filter_map(|event| serde_json::from_str(event.json().get()).ok())
                 .filter_map(|event: serde_json::Value| event.get("sender").cloned())
                 .filter_map(|sender| sender.as_str().map(|s| s.to_owned()))
-                .filter_map(|sender| UserId::try_from(sender).ok())
+                .filter_map(|sender| Box::<UserId>::try_from(sender).ok())
                 .map(|user| user.server_name().to_owned())
                 .collect();
 
@@ -127,7 +127,7 @@ pub async fn join_room_by_id_or_alias_route(
 
     let join_room_response = join_room_by_id_helper(
         &db,
-        body.sender_user.as_ref(),
+        body.sender_user.as_deref(),
         &room_id,
         &servers,
         body.third_party_signed.as_ref(),
@@ -531,7 +531,7 @@ async fn join_room_by_id_helper(
             .roomid_mutex_state
             .write()
             .unwrap()
-            .entry(room_id.clone())
+            .entry(room_id.to_owned())
             .or_default(),
     );
     let state_lock = mutex_state.lock().await;
@@ -551,7 +551,7 @@ async fn join_room_by_id_helper(
                     federation::membership::create_join_event_template::v1::Request {
                         room_id,
                         user_id: sender_user,
-                        ver: &[RoomVersionId::Version5, RoomVersionId::Version6],
+                        ver: &[RoomVersionId::V5, RoomVersionId::V6],
                     },
                 )
                 .await;
@@ -567,8 +567,7 @@ async fn join_room_by_id_helper(
 
         let room_version = match make_join_response.room_version {
             Some(room_version)
-                if room_version == RoomVersionId::Version5
-                    || room_version == RoomVersionId::Version6 =>
+                if room_version == RoomVersionId::V5 || room_version == RoomVersionId::V6 =>
             {
                 room_version
             }
@@ -620,7 +619,7 @@ async fn join_room_by_id_helper(
         .expect("event is valid, we just created it");
 
         // Generate event id
-        let event_id = EventId::try_from(&*format!(
+        let event_id = Box::<EventId>::try_from(&*format!(
             "${}",
             ruma::signatures::reference_hash(&join_event_stub, &room_version)
                 .expect("ruma can calculate reference hashes")
@@ -776,7 +775,7 @@ async fn join_room_by_id_helper(
 
     db.flush()?;
 
-    Ok(join_room_by_id::Response::new(room_id.clone()).into())
+    Ok(join_room_by_id::Response::new(room_id.to_owned()).into())
 }
 
 fn validate_and_add_event_id(
@@ -784,12 +783,12 @@ fn validate_and_add_event_id(
     room_version: &RoomVersionId,
     pub_key_map: &RwLock<BTreeMap<String, BTreeMap<String, String>>>,
     db: &Database,
-) -> Result<(EventId, CanonicalJsonObject)> {
+) -> Result<(Box<EventId>, CanonicalJsonObject)> {
     let mut value: CanonicalJsonObject = serde_json::from_str(pdu.get()).map_err(|e| {
         error!("Invalid PDU in server response: {:?}: {:?}", pdu, e);
         Error::BadServerResponse("Invalid PDU in server response")
     })?;
-    let event_id = EventId::try_from(&*format!(
+    let event_id = Box::<EventId>::try_from(&*format!(
         "${}",
         ruma::signatures::reference_hash(&value, room_version)
             .expect("ruma can calculate reference hashes")
@@ -856,7 +855,7 @@ pub(crate) async fn invite_helper<'a>(
                     .roomid_mutex_state
                     .write()
                     .unwrap()
-                    .entry(room_id.clone())
+                    .entry(room_id.to_owned())
                     .or_default(),
             );
             let state_lock = mutex_state.lock().await;
@@ -892,9 +891,7 @@ pub(crate) async fn invite_helper<'a>(
 
             // If there was no create event yet, assume we are creating a version 6 room right now
             let room_version_id = create_event_content
-                .map_or(RoomVersionId::Version6, |create_event| {
-                    create_event.room_version
-                });
+                .map_or(RoomVersionId::V6, |create_event| create_event.room_version);
             let room_version =
                 RoomVersion::new(&room_version_id).expect("room version is supported");
 
@@ -939,9 +936,9 @@ pub(crate) async fn invite_helper<'a>(
             }
 
             let pdu = PduEvent {
-                event_id: ruma::event_id!("$thiswillbefilledinlater"),
-                room_id: room_id.clone(),
-                sender: sender_user.clone(),
+                event_id: ruma::event_id!("$thiswillbefilledinlater").to_owned(),
+                room_id: room_id.to_owned(),
+                sender: sender_user.to_owned(),
                 origin_server_ts: utils::millis_since_unix_epoch()
                     .try_into()
                     .expect("time is valid"),
@@ -1014,7 +1011,7 @@ pub(crate) async fn invite_helper<'a>(
         };
 
         // Generate event id
-        let expected_event_id = EventId::try_from(&*format!(
+        let expected_event_id = Box::<EventId>::try_from(&*format!(
             "${}",
             ruma::signatures::reference_hash(&pdu_json, &room_version_id)
                 .expect("ruma can calculate reference hashes")
@@ -1100,7 +1097,7 @@ pub(crate) async fn invite_helper<'a>(
             .roomid_mutex_state
             .write()
             .unwrap()
-            .entry(room_id.clone())
+            .entry(room_id.to_owned())
             .or_default(),
     );
     let state_lock = mutex_state.lock().await;
diff --git a/src/client_server/message.rs b/src/client_server/message.rs
index abbbe8ea869c3f59e66ac9484212ddbafdd3efe2..0d006101fb880180b780e8ad4c2864cc2451d93f 100644
--- a/src/client_server/message.rs
+++ b/src/client_server/message.rs
@@ -67,7 +67,7 @@ pub async fn send_message_event_route(
             ));
         }
 
-        let event_id = EventId::try_from(
+        let event_id = Box::<EventId>::try_from(
             utils::string_from_bytes(&response)
                 .map_err(|_| Error::bad_database("Invalid txnid bytes in database."))?,
         )
diff --git a/src/client_server/report.rs b/src/client_server/report.rs
index 3dcb4d1c74787c19455261fb2a82fc6ec21bdb1e..2e6527d4a7cf6a3ee88df1711167fd1135bf1232 100644
--- a/src/client_server/report.rs
+++ b/src/client_server/report.rs
@@ -57,8 +57,7 @@ pub async fn report_event_route(
                 Report Score: {}\n\
                 Report Reason: {}",
                 sender_user, pdu.event_id, pdu.room_id, pdu.sender, body.score, body.reason
-            )
-            .to_owned(),
+            ),
             format!(
                 "<details><summary>Report received from: <a href=\"https://matrix.to/#/{0}\">{0}\
                 </a></summary><ul><li>Event Info<ul><li>Event ID: <code>{1}</code>\
@@ -72,8 +71,7 @@ pub async fn report_event_route(
                 pdu.sender,
                 body.score,
                 RawStr::new(&body.reason).html_escape()
-            )
-            .to_owned(),
+            ),
         ),
     ));
 
diff --git a/src/client_server/room.rs b/src/client_server/room.rs
index 47c7ee6f552c29bc28b08465202cc21183f34401..97b3f482abe8fec480832c39860ecc3918e04993 100644
--- a/src/client_server/room.rs
+++ b/src/client_server/room.rs
@@ -88,14 +88,17 @@ pub async fn create_room_route(
         ));
     }
 
-    let alias: Option<RoomAliasId> =
+    let alias: Option<Box<RoomAliasId>> =
         body.room_alias_name
             .as_ref()
             .map_or(Ok(None), |localpart| {
                 // TODO: Check for invalid characters and maximum length
-                let alias =
-                    RoomAliasId::try_from(format!("#{}:{}", localpart, db.globals.server_name()))
-                        .map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, "Invalid alias."))?;
+                let alias = Box::<RoomAliasId>::try_from(format!(
+                    "#{}:{}",
+                    localpart,
+                    db.globals.server_name(),
+                ))
+                .map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, "Invalid alias."))?;
 
                 if db.rooms.id_from_alias(&alias)?.is_some() {
                     Err(Error::BadRequest(
@@ -109,7 +112,7 @@ pub async fn create_room_route(
 
     let room_version = match body.room_version.clone() {
         Some(room_version) => {
-            if room_version == RoomVersionId::Version5 || room_version == RoomVersionId::Version6 {
+            if room_version == RoomVersionId::V5 || room_version == RoomVersionId::V6 {
                 room_version
             } else {
                 return Err(Error::BadRequest(
@@ -118,7 +121,7 @@ pub async fn create_room_route(
                 ));
             }
         }
-        None => RoomVersionId::Version6,
+        None => RoomVersionId::V6,
     };
 
     let content = match &body.creation_content {
@@ -164,7 +167,7 @@ pub async fn create_room_route(
             .get(),
     );
 
-    if let Err(_) = de_result {
+    if de_result.is_err() {
         return Err(Error::BadRequest(
             ErrorKind::BadJson,
             "Invalid creation content",
@@ -269,7 +272,7 @@ pub async fn create_room_route(
             PduBuilder {
                 event_type: EventType::RoomCanonicalAlias,
                 content: to_raw_value(&RoomCanonicalAliasEventContent {
-                    alias: Some(room_alias_id.clone()),
+                    alias: Some(room_alias_id.to_owned()),
                     alt_aliases: vec![],
                 })
                 .expect("We checked that alias earlier, it must be fine"),
@@ -505,10 +508,7 @@ pub async fn upgrade_room_route(
 ) -> ConduitResult<upgrade_room::Response> {
     let sender_user = body.sender_user.as_ref().expect("user is authenticated");
 
-    if !matches!(
-        body.new_version,
-        RoomVersionId::Version5 | RoomVersionId::Version6
-    ) {
+    if !matches!(body.new_version, RoomVersionId::V5 | RoomVersionId::V6) {
         return Err(Error::BadRequest(
             ErrorKind::UnsupportedRoomVersion,
             "This server does not support that room version.",
@@ -605,7 +605,7 @@ pub async fn upgrade_room_route(
             .get(),
     );
 
-    if let Err(_) = de_result {
+    if de_result.is_err() {
         return Err(Error::BadRequest(
             ErrorKind::BadJson,
             "Error forming creation event",
diff --git a/src/client_server/state.rs b/src/client_server/state.rs
index 307bccabcd2b0d19540aaaaade4c362fae1a38f7..0ba20620c85b10fe8cee3bebe8656e88fc04b8e8 100644
--- a/src/client_server/state.rs
+++ b/src/client_server/state.rs
@@ -267,7 +267,7 @@ async fn send_state_event_for_key_helper(
     event_type: EventType,
     json: &Raw<AnyStateEventContent>,
     state_key: String,
-) -> Result<EventId> {
+) -> Result<Box<EventId>> {
     let sender_user = sender;
 
     // TODO: Review this check, error if event is unparsable, use event type, allow alias if it
@@ -303,7 +303,7 @@ async fn send_state_event_for_key_helper(
             .roomid_mutex_state
             .write()
             .unwrap()
-            .entry(room_id.clone())
+            .entry(room_id.to_owned())
             .or_default(),
     );
     let state_lock = mutex_state.lock().await;
diff --git a/src/client_server/sync.rs b/src/client_server/sync.rs
index 65c07bc932f0cda5f27020ca4071474917fa72d7..1060d9176fa691e5c9241e139817dfc8344fb77c 100644
--- a/src/client_server/sync.rs
+++ b/src/client_server/sync.rs
@@ -54,15 +54,17 @@
 /// `since` will be cached
 #[cfg_attr(
     feature = "conduit_bin",
-    get("/_matrix/client/r0/sync", data = "<body>")
+    get("/_matrix/client/r0/sync", data = "<req>")
 )]
-#[tracing::instrument(skip(db, body))]
+#[tracing::instrument(skip(db, req))]
 pub async fn sync_events_route(
     db: DatabaseGuard,
-    body: Ruma<sync_events::Request<'_>>,
+    req: Ruma<sync_events::Request<'_>>,
 ) -> Result<RumaResponse<sync_events::Response>, RumaResponse<UiaaResponse>> {
-    let sender_user = body.sender_user.as_ref().expect("user is authenticated");
-    let sender_device = body.sender_device.as_ref().expect("user is authenticated");
+    let body = req.body;
+
+    let sender_user = req.sender_user.expect("user is authenticated");
+    let sender_device = req.sender_device.expect("user is authenticated");
 
     let arc_db = Arc::new(db);
 
@@ -132,7 +134,7 @@ pub async fn sync_events_route(
 
 async fn sync_helper_wrapper(
     db: Arc<DatabaseGuard>,
-    sender_user: UserId,
+    sender_user: Box<UserId>,
     sender_device: Box<DeviceId>,
     since: Option<String>,
     full_state: bool,
@@ -176,7 +178,7 @@ async fn sync_helper_wrapper(
 
 async fn sync_helper(
     db: Arc<DatabaseGuard>,
-    sender_user: UserId,
+    sender_user: Box<UserId>,
     sender_device: Box<DeviceId>,
     since: Option<String>,
     full_state: bool,
@@ -296,9 +298,10 @@ async fn sync_helper(
                             })?;
 
                         if let Some(state_key) = &pdu.state_key {
-                            let user_id = UserId::try_from(state_key.clone()).map_err(|_| {
-                                Error::bad_database("Invalid UserId in member PDU.")
-                            })?;
+                            let user_id =
+                                Box::<UserId>::try_from(state_key.clone()).map_err(|_| {
+                                    Error::bad_database("Invalid UserId in member PDU.")
+                                })?;
 
                             // The membership was and still is invite or join
                             if matches!(
@@ -424,7 +427,7 @@ async fn sync_helper(
                     }
 
                     if let Some(state_key) = &state_event.state_key {
-                        let user_id = UserId::try_from(state_key.clone())
+                        let user_id = Box::<UserId>::try_from(state_key.clone())
                             .map_err(|_| Error::bad_database("Invalid UserId in member PDU."))?;
 
                         if user_id == sender_user {
@@ -793,7 +796,7 @@ fn share_encrypted_room(
 ) -> Result<bool> {
     Ok(db
         .rooms
-        .get_shared_rooms(vec![sender_user.clone(), user_id.clone()])?
+        .get_shared_rooms(vec![sender_user.to_owned(), user_id.to_owned()])?
         .filter_map(|r| r.ok())
         .filter(|room_id| room_id != ignore_room)
         .filter_map(|other_room_id| {
diff --git a/src/client_server/voip.rs b/src/client_server/voip.rs
index c9a98d9f4d7f90ea2db3399dfcb9c30246e0267f..66a85f0f4e1e54db5bb7e7ee0f1e2fe28e9ac8c7 100644
--- a/src/client_server/voip.rs
+++ b/src/client_server/voip.rs
@@ -26,7 +26,7 @@ pub async fn turn_server_route(
 
     let turn_secret = db.globals.turn_secret();
 
-    let (username, password) = if turn_secret != "" {
+    let (username, password) = if !turn_secret.is_empty() {
         let expiry = SecondsSinceUnixEpoch::from_system_time(
             SystemTime::now() + Duration::from_secs(db.globals.turn_ttl()),
         )
diff --git a/src/database.rs b/src/database.rs
index 080e24b3e9cc4a8c275d36d36efd1d72c4b05289..056d49adad614dcd0f7280e420e9f08b26839cda 100644
--- a/src/database.rs
+++ b/src/database.rs
@@ -477,7 +477,8 @@ pub async fn load_or_create(config: &Config) -> Result<Arc<TokioRwLock<Self>>> {
                 // Set room member count
                 for (roomid, _) in db.rooms.roomid_shortstatehash.iter() {
                     let room_id =
-                        RoomId::try_from(utils::string_from_bytes(&roomid).unwrap()).unwrap();
+                        Box::<RoomId>::try_from(utils::string_from_bytes(&roomid).unwrap())
+                            .unwrap();
 
                     db.rooms.update_joined_count(&room_id, &db)?;
                 }
@@ -489,7 +490,7 @@ pub async fn load_or_create(config: &Config) -> Result<Arc<TokioRwLock<Self>>> {
 
             if db.globals.database_version()? < 7 {
                 // Upgrade state store
-                let mut last_roomstates: HashMap<RoomId, u64> = HashMap::new();
+                let mut last_roomstates: HashMap<Box<RoomId>, u64> = HashMap::new();
                 let mut current_sstatehash: Option<u64> = None;
                 let mut current_room = None;
                 let mut current_state = HashSet::new();
@@ -570,7 +571,7 @@ pub async fn load_or_create(config: &Config) -> Result<Arc<TokioRwLock<Self>>> {
                         if let Some(current_sstatehash) = current_sstatehash {
                             handle_state(
                                 current_sstatehash,
-                                current_room.as_ref().unwrap(),
+                                current_room.as_deref().unwrap(),
                                 current_state,
                                 &mut last_roomstates,
                             )?;
@@ -587,7 +588,7 @@ pub async fn load_or_create(config: &Config) -> Result<Arc<TokioRwLock<Self>>> {
                             .unwrap()
                             .unwrap();
                         let event_id =
-                            EventId::try_from(utils::string_from_bytes(&event_id).unwrap())
+                            Box::<EventId>::try_from(utils::string_from_bytes(&event_id).unwrap())
                                 .unwrap();
                         let pdu = db.rooms.get_pdu(&event_id).unwrap().unwrap();
 
@@ -604,7 +605,7 @@ pub async fn load_or_create(config: &Config) -> Result<Arc<TokioRwLock<Self>>> {
                 if let Some(current_sstatehash) = current_sstatehash {
                     handle_state(
                         current_sstatehash,
-                        current_room.as_ref().unwrap(),
+                        current_room.as_deref().unwrap(),
                         current_state,
                         &mut last_roomstates,
                     )?;
diff --git a/src/database/admin.rs b/src/database/admin.rs
index 8d8559a5929f380bafd1767811c367d301e121f8..07a487e27619bd76542e62ceb51e0da93c20f4ed 100644
--- a/src/database/admin.rs
+++ b/src/database/admin.rs
@@ -1,13 +1,10 @@
-use std::{
-    convert::{TryFrom, TryInto},
-    sync::Arc,
-};
+use std::{convert::TryFrom, sync::Arc};
 
 use crate::{pdu::PduBuilder, Database};
 use rocket::futures::{channel::mpsc, stream::StreamExt};
 use ruma::{
     events::{room::message::RoomMessageEventContent, EventType},
-    UserId,
+    RoomAliasId, UserId,
 };
 use serde_json::value::to_raw_value;
 use tokio::sync::{MutexGuard, RwLock, RwLockReadGuard};
@@ -37,15 +34,17 @@ pub fn start_handler(
             let guard = db.read().await;
 
             let conduit_user =
-                UserId::try_from(format!("@conduit:{}", guard.globals.server_name()))
+                Box::<UserId>::try_from(format!("@conduit:{}", guard.globals.server_name()))
                     .expect("@conduit:server_name is valid");
 
             let conduit_room = guard
                 .rooms
                 .id_from_alias(
-                    &format!("#admins:{}", guard.globals.server_name())
-                        .try_into()
-                        .expect("#admins:server_name is a valid room alias"),
+                    &Box::<RoomAliasId>::try_from(format!(
+                        "#admins:{}",
+                        guard.globals.server_name()
+                    ))
+                    .expect("#admins:server_name is a valid room alias"),
                 )
                 .unwrap();
 
diff --git a/src/database/globals.rs b/src/database/globals.rs
index 05ecb568821886245bea5e15109a0118f1a6bbfa..098d81978a0abbd0a2217d425134ce3e1a0bb11f 100644
--- a/src/database/globals.rs
+++ b/src/database/globals.rs
@@ -40,13 +40,13 @@ pub struct Globals {
     dns_resolver: TokioAsyncResolver,
     jwt_decoding_key: Option<jsonwebtoken::DecodingKey<'static>>,
     pub(super) server_signingkeys: Arc<dyn Tree>,
-    pub bad_event_ratelimiter: Arc<RwLock<HashMap<EventId, RateLimitState>>>,
+    pub bad_event_ratelimiter: Arc<RwLock<HashMap<Box<EventId>, RateLimitState>>>,
     pub bad_signature_ratelimiter: Arc<RwLock<HashMap<Vec<String>, RateLimitState>>>,
     pub servername_ratelimiter: Arc<RwLock<HashMap<Box<ServerName>, Arc<Semaphore>>>>,
-    pub sync_receivers: RwLock<HashMap<(UserId, Box<DeviceId>), SyncHandle>>,
-    pub roomid_mutex_insert: RwLock<HashMap<RoomId, Arc<Mutex<()>>>>,
-    pub roomid_mutex_state: RwLock<HashMap<RoomId, Arc<TokioMutex<()>>>>,
-    pub roomid_mutex_federation: RwLock<HashMap<RoomId, Arc<TokioMutex<()>>>>, // this lock will be held longer
+    pub sync_receivers: RwLock<HashMap<(Box<UserId>, Box<DeviceId>), SyncHandle>>,
+    pub roomid_mutex_insert: RwLock<HashMap<Box<RoomId>, Arc<Mutex<()>>>>,
+    pub roomid_mutex_state: RwLock<HashMap<Box<RoomId>, Arc<TokioMutex<()>>>>,
+    pub roomid_mutex_federation: RwLock<HashMap<Box<RoomId>, Arc<TokioMutex<()>>>>, // this lock will be held longer
     pub rotate: RotationHandler,
 }
 
@@ -254,7 +254,7 @@ pub fn add_signing_key(
         &self,
         origin: &ServerName,
         new_keys: ServerSigningKeys,
-    ) -> Result<BTreeMap<ServerSigningKeyId, VerifyKey>> {
+    ) -> Result<BTreeMap<Box<ServerSigningKeyId>, VerifyKey>> {
         // Not atomic, but this is not critical
         let signingkeys = self.server_signingkeys.get(origin.as_bytes())?;
 
@@ -293,7 +293,7 @@ pub fn add_signing_key(
     pub fn signing_keys_for(
         &self,
         origin: &ServerName,
-    ) -> Result<BTreeMap<ServerSigningKeyId, VerifyKey>> {
+    ) -> Result<BTreeMap<Box<ServerSigningKeyId>, VerifyKey>> {
         let signingkeys = self
             .server_signingkeys
             .get(origin.as_bytes())?
diff --git a/src/database/key_backups.rs b/src/database/key_backups.rs
index 98ea01118596fa03e92c7cdae88ca6b2f293e5f7..3010a37b073e1876eda8cc9b9687cf3daa5e9137 100644
--- a/src/database/key_backups.rs
+++ b/src/database/key_backups.rs
@@ -209,13 +209,13 @@ pub fn get_all(
         &self,
         user_id: &UserId,
         version: &str,
-    ) -> Result<BTreeMap<RoomId, RoomKeyBackup>> {
+    ) -> Result<BTreeMap<Box<RoomId>, RoomKeyBackup>> {
         let mut prefix = user_id.as_bytes().to_vec();
         prefix.push(0xff);
         prefix.extend_from_slice(version.as_bytes());
         prefix.push(0xff);
 
-        let mut rooms = BTreeMap::<RoomId, RoomKeyBackup>::new();
+        let mut rooms = BTreeMap::<Box<RoomId>, RoomKeyBackup>::new();
 
         for result in self
             .backupkeyid_backup
@@ -231,7 +231,7 @@ pub fn get_all(
                         Error::bad_database("backupkeyid_backup session_id is invalid.")
                     })?;
 
-                let room_id = RoomId::try_from(
+                let room_id = Box::<RoomId>::try_from(
                     utils::string_from_bytes(parts.next().ok_or_else(|| {
                         Error::bad_database("backupkeyid_backup key is invalid.")
                     })?)
diff --git a/src/database/pusher.rs b/src/database/pusher.rs
index f53f137b27ad3d98b7630e5f50228f218ce7fa5c..97ca85d8b667e347aea7d71d0694558fc1823ee8 100644
--- a/src/database/pusher.rs
+++ b/src/database/pusher.rs
@@ -234,7 +234,7 @@ pub fn get_actions<'a>(
     db: &Database,
 ) -> Result<&'a [Action]> {
     let ctx = PushConditionRoomCtx {
-        room_id: room_id.clone(),
+        room_id: room_id.to_owned(),
         member_count: 10_u32.into(), // TODO: get member count efficiently
         user_display_name: db
             .users
@@ -277,7 +277,7 @@ async fn send_notice(
     let mut data_minus_url = pusher.data.clone();
     // The url must be stripped off according to spec
     data_minus_url.url = None;
-    device.data = Some(data_minus_url);
+    device.data = data_minus_url;
 
     // Tweaks are only added if the format is NOT event_id_only
     if !event_id_only {
diff --git a/src/database/rooms.rs b/src/database/rooms.rs
index c5b795bd01c62c86c2821c33989883a5d4b49c00..ebd0941b4c122b9d65c646e03d5df402bf22903d 100644
--- a/src/database/rooms.rs
+++ b/src/database/rooms.rs
@@ -107,14 +107,14 @@ pub struct Rooms {
     /// RoomId + EventId -> Parent PDU EventId.
     pub(super) referencedevents: Arc<dyn Tree>,
 
-    pub(super) pdu_cache: Mutex<LruCache<EventId, Arc<PduEvent>>>,
+    pub(super) pdu_cache: Mutex<LruCache<Box<EventId>, Arc<PduEvent>>>,
     pub(super) shorteventid_cache: Mutex<LruCache<u64, Arc<EventId>>>,
     pub(super) auth_chain_cache: Mutex<LruCache<Vec<u64>, Arc<HashSet<u64>>>>,
-    pub(super) eventidshort_cache: Mutex<LruCache<EventId, u64>>,
+    pub(super) eventidshort_cache: Mutex<LruCache<Box<EventId>, u64>>,
     pub(super) statekeyshort_cache: Mutex<LruCache<(EventType, String), u64>>,
     pub(super) shortstatekey_cache: Mutex<LruCache<u64, (EventType, String)>>,
-    pub(super) our_real_users_cache: RwLock<HashMap<RoomId, Arc<HashSet<UserId>>>>,
-    pub(super) appservice_in_room_cache: RwLock<HashMap<RoomId, HashMap<String, bool>>>,
+    pub(super) our_real_users_cache: RwLock<HashMap<Box<RoomId>, Arc<HashSet<Box<UserId>>>>>,
+    pub(super) appservice_in_room_cache: RwLock<HashMap<Box<RoomId>, HashMap<String, bool>>>,
     pub(super) stateinfo_cache: Mutex<
         LruCache<
             u64,
@@ -434,7 +434,7 @@ struct ExtractMembership {
                 None => continue,
             };
 
-            let user_id = match UserId::try_from(state_key) {
+            let user_id = match Box::<UserId>::try_from(state_key) {
                 Ok(id) => id,
                 Err(_) => continue,
             };
@@ -742,7 +742,7 @@ pub fn get_or_create_shorteventid(
         self.eventidshort_cache
             .lock()
             .unwrap()
-            .insert(event_id.clone(), short);
+            .insert(event_id.to_owned(), short);
 
         Ok(short)
     }
@@ -871,8 +871,8 @@ pub fn get_eventid_from_short(&self, shorteventid: u64) -> Result<Arc<EventId>>
             .get(&shorteventid.to_be_bytes())?
             .ok_or_else(|| Error::bad_database("Shorteventid does not exist"))?;
 
-        let event_id = Arc::new(
-            EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
+        let event_id = Arc::from(
+            Box::<EventId>::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
                 Error::bad_database("EventID in shorteventid_eventid is invalid unicode.")
             })?)
             .map_err(|_| Error::bad_database("EventId in shorteventid_eventid is invalid."))?,
@@ -1112,7 +1112,7 @@ pub fn get_pdu(&self, event_id: &EventId) -> Result<Option<Arc<PduEvent>>> {
             self.pdu_cache
                 .lock()
                 .unwrap()
-                .insert(event_id.clone(), Arc::clone(&pdu));
+                .insert(event_id.to_owned(), Arc::clone(&pdu));
             Ok(Some(pdu))
         } else {
             Ok(None)
@@ -1162,14 +1162,14 @@ fn replace_pdu(&self, pdu_id: &[u8], pdu: &PduEvent) -> Result<()> {
 
     /// Returns the leaf pdus of a room.
     #[tracing::instrument(skip(self))]
-    pub fn get_pdu_leaves(&self, room_id: &RoomId) -> Result<HashSet<EventId>> {
+    pub fn get_pdu_leaves(&self, room_id: &RoomId) -> Result<HashSet<Box<EventId>>> {
         let mut prefix = room_id.as_bytes().to_vec();
         prefix.push(0xff);
 
         self.roomid_pduleaves
             .scan_prefix(prefix)
             .map(|(_, bytes)| {
-                EventId::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
+                Box::<EventId>::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
                     Error::bad_database("EventID in roomid_pduleaves is invalid unicode.")
                 })?)
                 .map_err(|_| Error::bad_database("EventId in roomid_pduleaves is invalid."))
@@ -1178,7 +1178,7 @@ pub fn get_pdu_leaves(&self, room_id: &RoomId) -> Result<HashSet<EventId>> {
     }
 
     #[tracing::instrument(skip(self, room_id, event_ids))]
-    pub fn mark_as_referenced(&self, room_id: &RoomId, event_ids: &[EventId]) -> Result<()> {
+    pub fn mark_as_referenced(&self, room_id: &RoomId, event_ids: &[Box<EventId>]) -> Result<()> {
         for prev in event_ids {
             let mut key = room_id.as_bytes().to_vec();
             key.extend_from_slice(prev.as_bytes());
@@ -1193,7 +1193,7 @@ pub fn mark_as_referenced(&self, room_id: &RoomId, event_ids: &[EventId]) -> Res
     /// The provided `event_ids` become the new leaves, this allows a room to have multiple
     /// `prev_events`.
     #[tracing::instrument(skip(self))]
-    pub fn replace_pdu_leaves(&self, room_id: &RoomId, event_ids: &[EventId]) -> Result<()> {
+    pub fn replace_pdu_leaves(&self, room_id: &RoomId, event_ids: &[Box<EventId>]) -> Result<()> {
         let mut prefix = room_id.as_bytes().to_vec();
         prefix.push(0xff);
 
@@ -1261,7 +1261,7 @@ pub fn append_pdu(
         &self,
         pdu: &PduEvent,
         mut pdu_json: CanonicalJsonObject,
-        leaves: &[EventId],
+        leaves: &[Box<EventId>],
         db: &Database,
     ) -> Result<Vec<u8>> {
         let shortroomid = self.get_shortroomid(&pdu.room_id)?.expect("room exists");
@@ -1420,7 +1420,7 @@ struct ExtractMembership {
                     }
 
                     // if the state_key fails
-                    let target_user_id = UserId::try_from(state_key.clone())
+                    let target_user_id = Box::<UserId>::try_from(state_key.clone())
                         .expect("This state_key was previously validated");
 
                     let content = serde_json::from_str::<ExtractMembership>(pdu.content.get())
@@ -1476,9 +1476,11 @@ struct ExtractBody<'a> {
                     if body.starts_with(&format!("@conduit:{}: ", db.globals.server_name()))
                         && self
                             .id_from_alias(
-                                &format!("#admins:{}", db.globals.server_name())
-                                    .try_into()
-                                    .expect("#admins:server_name is a valid room alias"),
+                                &Box::<RoomAliasId>::try_from(format!(
+                                    "#admins:{}",
+                                    db.globals.server_name()
+                                ))
+                                .expect("#admins:server_name is a valid room alias"),
                             )?
                             .as_ref()
                             == Some(&pdu.room_id)
@@ -1528,7 +1530,7 @@ struct ExtractBody<'a> {
                                 }
                                 "get_auth_chain" => {
                                     if args.len() == 1 {
-                                        if let Ok(event_id) = EventId::try_from(args[0]) {
+                                        if let Ok(event_id) = Box::<EventId>::try_from(args[0]) {
                                             if let Some(event) = db.rooms.get_pdu_json(&event_id)? {
                                                 let room_id_str = event
                                                     .get("room_id")
@@ -1539,12 +1541,12 @@ struct ExtractBody<'a> {
                                                         )
                                                     })?;
 
-                                                let room_id = RoomId::try_from(room_id_str)
+                                                let room_id = Box::<RoomId>::try_from(room_id_str)
                                                 .map_err(|_| Error::bad_database("Invalid room id field in event in database"))?;
                                                 let start = Instant::now();
                                                 let count = server_server::get_auth_chain(
                                                     &room_id,
-                                                    vec![Arc::new(event_id)],
+                                                    vec![Arc::from(event_id)],
                                                     db,
                                                 )?
                                                 .count();
@@ -1567,12 +1569,12 @@ struct ExtractBody<'a> {
                                         let string = body[1..body.len() - 1].join("\n");
                                         match serde_json::from_str(&string) {
                                             Ok(value) => {
-                                                let event_id = EventId::try_from(&*format!(
+                                                let event_id = Box::<EventId>::try_from(&*format!(
                                                     "${}",
                                                     // Anything higher than version3 behaves the same
                                                     ruma::signatures::reference_hash(
                                                         &value,
-                                                        &RoomVersionId::Version6
+                                                        &RoomVersionId::V6
                                                     )
                                                     .expect("ruma can calculate reference hashes")
                                                 ))
@@ -1622,7 +1624,7 @@ struct ExtractBody<'a> {
                                 }
                                 "get_pdu" => {
                                     if args.len() == 1 {
-                                        if let Ok(event_id) = EventId::try_from(args[0]) {
+                                        if let Ok(event_id) = Box::<EventId>::try_from(args[0]) {
                                             let mut outlier = false;
                                             let mut pdu_json =
                                                 db.rooms.get_non_outlier_pdu_json(&event_id)?;
@@ -1948,7 +1950,7 @@ pub fn build_and_append_pdu(
         room_id: &RoomId,
         db: &Database,
         _mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room mutex
-    ) -> Result<EventId> {
+    ) -> Result<Box<EventId>> {
         let PduBuilder {
             event_type,
             content,
@@ -1985,9 +1987,7 @@ pub fn build_and_append_pdu(
 
         // If there was no create event yet, assume we are creating a version 6 room right now
         let room_version_id = create_event_content
-            .map_or(RoomVersionId::Version6, |create_event| {
-                create_event.room_version
-            });
+            .map_or(RoomVersionId::V6, |create_event| create_event.room_version);
         let room_version = RoomVersion::new(&room_version_id).expect("room version is supported");
 
         let auth_events =
@@ -2016,9 +2016,9 @@ pub fn build_and_append_pdu(
         }
 
         let mut pdu = PduEvent {
-            event_id: ruma::event_id!("$thiswillbefilledinlater"),
-            room_id: room_id.clone(),
-            sender: sender.clone(),
+            event_id: ruma::event_id!("$thiswillbefilledinlater").to_owned(),
+            room_id: room_id.to_owned(),
+            sender: sender.to_owned(),
             origin_server_ts: utils::millis_since_unix_epoch()
                 .try_into()
                 .expect("time is valid"),
@@ -2083,7 +2083,7 @@ pub fn build_and_append_pdu(
         .expect("event is valid, we just created it");
 
         // Generate event id
-        pdu.event_id = EventId::try_from(&*format!(
+        pdu.event_id = Box::<EventId>::try_from(&*format!(
             "${}",
             ruma::signatures::reference_hash(&pdu_json, &room_version_id)
                 .expect("ruma can calculate reference hashes")
@@ -2206,7 +2206,7 @@ pub fn pdus_since<'a>(
         let mut first_pdu_id = prefix.clone();
         first_pdu_id.extend_from_slice(&(since + 1).to_be_bytes());
 
-        let user_id = user_id.clone();
+        let user_id = user_id.to_owned();
 
         Ok(self
             .pduid_pdu
@@ -2243,7 +2243,7 @@ pub fn pdus_until<'a>(
 
         let current: &[u8] = &current;
 
-        let user_id = user_id.clone();
+        let user_id = user_id.to_owned();
 
         Ok(self
             .pduid_pdu
@@ -2280,7 +2280,7 @@ pub fn pdus_after<'a>(
 
         let current: &[u8] = &current;
 
-        let user_id = user_id.clone();
+        let user_id = user_id.to_owned();
 
         Ok(self
             .pduid_pdu
@@ -2412,7 +2412,7 @@ pub fn update_membership(
 
                             for room_ids in direct_event.content.0.values_mut() {
                                 if room_ids.iter().any(|r| r == &predecessor.room_id) {
-                                    room_ids.push(room_id.clone());
+                                    room_ids.push(room_id.to_owned());
                                     room_ids_updated = true;
                                 }
                             }
@@ -2451,7 +2451,11 @@ pub fn update_membership(
                         EventType::IgnoredUserList,
                     )?
                     .map_or(false, |ignored| {
-                        ignored.content.ignored_users.contains(sender)
+                        ignored
+                            .content
+                            .ignored_users
+                            .iter()
+                            .any(|user| user == sender)
                     });
 
                 if is_ignored {
@@ -2537,7 +2541,7 @@ pub fn update_joined_count(&self, room_id: &RoomId, db: &Database) -> Result<()>
         self.our_real_users_cache
             .write()
             .unwrap()
-            .insert(room_id.clone(), Arc::new(real_users));
+            .insert(room_id.to_owned(), Arc::new(real_users));
 
         for old_joined_server in self.room_servers(room_id).filter_map(|r| r.ok()) {
             if !joined_servers.remove(&old_joined_server) {
@@ -2582,7 +2586,7 @@ pub fn get_our_real_users(
         &self,
         room_id: &RoomId,
         db: &Database,
-    ) -> Result<Arc<HashSet<UserId>>> {
+    ) -> Result<Arc<HashSet<Box<UserId>>>> {
         let maybe = self
             .our_real_users_cache
             .read()
@@ -2650,7 +2654,7 @@ pub fn appservice_in_room(
             self.appservice_in_room_cache
                 .write()
                 .unwrap()
-                .entry(room_id.clone())
+                .entry(room_id.to_owned())
                 .or_default()
                 .insert(appservice.0.clone(), in_room);
 
@@ -2694,7 +2698,7 @@ pub async fn leave_room(
                     .roomid_mutex_state
                     .write()
                     .unwrap()
-                    .entry(room_id.clone())
+                    .entry(room_id.to_owned())
                     .or_default(),
             );
             let state_lock = mutex_state.lock().await;
@@ -2754,7 +2758,7 @@ async fn remote_leave_room(
             .filter_map(|event| serde_json::from_str(event.json().get()).ok())
             .filter_map(|event: serde_json::Value| event.get("sender").cloned())
             .filter_map(|sender| sender.as_str().map(|s| s.to_owned()))
-            .filter_map(|sender| UserId::try_from(sender).ok())
+            .filter_map(|sender| Box::<UserId>::try_from(sender).ok())
             .map(|user| user.server_name().to_owned())
             .collect();
 
@@ -2778,9 +2782,7 @@ async fn remote_leave_room(
         let (make_leave_response, remote_server) = make_leave_response_and_server?;
 
         let room_version_id = match make_leave_response.room_version {
-            Some(version)
-                if version == RoomVersionId::Version5 || version == RoomVersionId::Version6 =>
-            {
+            Some(version) if version == RoomVersionId::V5 || version == RoomVersionId::V6 => {
                 version
             }
             _ => return Err(Error::BadServerResponse("Room version is not supported")),
@@ -2817,7 +2819,7 @@ async fn remote_leave_room(
         .expect("event is valid, we just created it");
 
         // Generate event id
-        let event_id = EventId::try_from(&*format!(
+        let event_id = Box::<EventId>::try_from(&*format!(
             "${}",
             ruma::signatures::reference_hash(&leave_event_stub, &room_version_id)
                 .expect("ruma can calculate reference hashes")
@@ -2902,11 +2904,11 @@ pub fn set_alias(
     }
 
     #[tracing::instrument(skip(self))]
-    pub fn id_from_alias(&self, alias: &RoomAliasId) -> Result<Option<RoomId>> {
+    pub fn id_from_alias(&self, alias: &RoomAliasId) -> Result<Option<Box<RoomId>>> {
         self.alias_roomid
             .get(alias.alias().as_bytes())?
             .map(|bytes| {
-                RoomId::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
+                Box::<RoomId>::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
                     Error::bad_database("Room ID in alias_roomid is invalid unicode.")
                 })?)
                 .map_err(|_| Error::bad_database("Room ID in alias_roomid is invalid."))
@@ -2918,7 +2920,7 @@ pub fn id_from_alias(&self, alias: &RoomAliasId) -> Result<Option<RoomId>> {
     pub fn room_aliases<'a>(
         &'a self,
         room_id: &RoomId,
-    ) -> impl Iterator<Item = Result<RoomAliasId>> + 'a {
+    ) -> impl Iterator<Item = Result<Box<RoomAliasId>>> + 'a {
         let mut prefix = room_id.as_bytes().to_vec();
         prefix.push(0xff);
 
@@ -2947,9 +2949,9 @@ pub fn is_public_room(&self, room_id: &RoomId) -> Result<bool> {
     }
 
     #[tracing::instrument(skip(self))]
-    pub fn public_rooms(&self) -> impl Iterator<Item = Result<RoomId>> + '_ {
+    pub fn public_rooms(&self) -> impl Iterator<Item = Result<Box<RoomId>>> + '_ {
         self.publicroomids.iter().map(|(bytes, _)| {
-            RoomId::try_from(
+            Box::<RoomId>::try_from(
                 utils::string_from_bytes(&bytes).map_err(|_| {
                     Error::bad_database("Room ID in publicroomids is invalid unicode.")
                 })?,
@@ -3009,8 +3011,8 @@ pub fn search_pdus<'a>(
     #[tracing::instrument(skip(self))]
     pub fn get_shared_rooms<'a>(
         &'a self,
-        users: Vec<UserId>,
-    ) -> Result<impl Iterator<Item = Result<RoomId>> + 'a> {
+        users: Vec<Box<UserId>>,
+    ) -> Result<impl Iterator<Item = Result<Box<RoomId>>> + 'a> {
         let iterators = users.into_iter().map(move |user_id| {
             let mut prefix = user_id.as_bytes().to_vec();
             prefix.push(0xff);
@@ -3037,7 +3039,7 @@ pub fn get_shared_rooms<'a>(
         Ok(utils::common_elements(iterators, Ord::cmp)
             .expect("users is not empty")
             .map(|bytes| {
-                RoomId::try_from(utils::string_from_bytes(&*bytes).map_err(|_| {
+                Box::<RoomId>::try_from(utils::string_from_bytes(&*bytes).map_err(|_| {
                     Error::bad_database("Invalid RoomId bytes in userroomid_joined")
                 })?)
                 .map_err(|_| Error::bad_database("Invalid RoomId in userroomid_joined."))
@@ -3082,12 +3084,12 @@ pub fn server_in_room<'a>(&'a self, server: &ServerName, room_id: &RoomId) -> Re
     pub fn server_rooms<'a>(
         &'a self,
         server: &ServerName,
-    ) -> impl Iterator<Item = Result<RoomId>> + 'a {
+    ) -> impl Iterator<Item = Result<Box<RoomId>>> + 'a {
         let mut prefix = server.as_bytes().to_vec();
         prefix.push(0xff);
 
         self.serverroomids.scan_prefix(prefix).map(|(key, _)| {
-            RoomId::try_from(
+            Box::<RoomId>::try_from(
                 utils::string_from_bytes(
                     key.rsplit(|&b| b == 0xff)
                         .next()
@@ -3104,12 +3106,12 @@ pub fn server_rooms<'a>(
     pub fn room_members<'a>(
         &'a self,
         room_id: &RoomId,
-    ) -> impl Iterator<Item = Result<UserId>> + 'a {
+    ) -> impl Iterator<Item = Result<Box<UserId>>> + 'a {
         let mut prefix = room_id.as_bytes().to_vec();
         prefix.push(0xff);
 
         self.roomuserid_joined.scan_prefix(prefix).map(|(key, _)| {
-            UserId::try_from(
+            Box::<UserId>::try_from(
                 utils::string_from_bytes(
                     key.rsplit(|&b| b == 0xff)
                         .next()
@@ -3150,14 +3152,14 @@ pub fn room_invited_count(&self, room_id: &RoomId) -> Result<Option<u64>> {
     pub fn room_useroncejoined<'a>(
         &'a self,
         room_id: &RoomId,
-    ) -> impl Iterator<Item = Result<UserId>> + 'a {
+    ) -> impl Iterator<Item = Result<Box<UserId>>> + 'a {
         let mut prefix = room_id.as_bytes().to_vec();
         prefix.push(0xff);
 
         self.roomuseroncejoinedids
             .scan_prefix(prefix)
             .map(|(key, _)| {
-                UserId::try_from(
+                Box::<UserId>::try_from(
                     utils::string_from_bytes(
                         key.rsplit(|&b| b == 0xff)
                             .next()
@@ -3176,14 +3178,14 @@ pub fn room_useroncejoined<'a>(
     pub fn room_members_invited<'a>(
         &'a self,
         room_id: &RoomId,
-    ) -> impl Iterator<Item = Result<UserId>> + 'a {
+    ) -> impl Iterator<Item = Result<Box<UserId>>> + 'a {
         let mut prefix = room_id.as_bytes().to_vec();
         prefix.push(0xff);
 
         self.roomuserid_invitecount
             .scan_prefix(prefix)
             .map(|(key, _)| {
-                UserId::try_from(
+                Box::<UserId>::try_from(
                     utils::string_from_bytes(
                         key.rsplit(|&b| b == 0xff)
                             .next()
@@ -3232,11 +3234,11 @@ pub fn get_left_count(&self, room_id: &RoomId, user_id: &UserId) -> Result<Optio
     pub fn rooms_joined<'a>(
         &'a self,
         user_id: &UserId,
-    ) -> impl Iterator<Item = Result<RoomId>> + 'a {
+    ) -> impl Iterator<Item = Result<Box<RoomId>>> + 'a {
         self.userroomid_joined
             .scan_prefix(user_id.as_bytes().to_vec())
             .map(|(key, _)| {
-                RoomId::try_from(
+                Box::<RoomId>::try_from(
                     utils::string_from_bytes(
                         key.rsplit(|&b| b == 0xff)
                             .next()
@@ -3255,14 +3257,14 @@ pub fn rooms_joined<'a>(
     pub fn rooms_invited<'a>(
         &'a self,
         user_id: &UserId,
-    ) -> impl Iterator<Item = Result<(RoomId, Vec<Raw<AnyStrippedStateEvent>>)>> + 'a {
+    ) -> impl Iterator<Item = Result<(Box<RoomId>, Vec<Raw<AnyStrippedStateEvent>>)>> + 'a {
         let mut prefix = user_id.as_bytes().to_vec();
         prefix.push(0xff);
 
         self.userroomid_invitestate
             .scan_prefix(prefix)
             .map(|(key, state)| {
-                let room_id = RoomId::try_from(
+                let room_id = Box::<RoomId>::try_from(
                     utils::string_from_bytes(
                         key.rsplit(|&b| b == 0xff)
                             .next()
@@ -3328,14 +3330,14 @@ pub fn left_state(
     pub fn rooms_left<'a>(
         &'a self,
         user_id: &UserId,
-    ) -> impl Iterator<Item = Result<(RoomId, Vec<Raw<AnySyncStateEvent>>)>> + 'a {
+    ) -> impl Iterator<Item = Result<(Box<RoomId>, Vec<Raw<AnySyncStateEvent>>)>> + 'a {
         let mut prefix = user_id.as_bytes().to_vec();
         prefix.push(0xff);
 
         self.userroomid_leftstate
             .scan_prefix(prefix)
             .map(|(key, state)| {
-                let room_id = RoomId::try_from(
+                let room_id = Box::<RoomId>::try_from(
                     utils::string_from_bytes(
                         key.rsplit(|&b| b == 0xff)
                             .next()
diff --git a/src/database/rooms/edus.rs b/src/database/rooms/edus.rs
index 9a27e43785c62b757f69963a63d0ba44dfc41f10..365211b63db6a02b6cb3360f51ea771d9599bb91 100644
--- a/src/database/rooms/edus.rs
+++ b/src/database/rooms/edus.rs
@@ -76,8 +76,13 @@ pub fn readreceipts_since<'a>(
         &'a self,
         room_id: &RoomId,
         since: u64,
-    ) -> impl Iterator<Item = Result<(UserId, u64, Raw<ruma::events::AnySyncEphemeralRoomEvent>)>> + 'a
-    {
+    ) -> impl Iterator<
+        Item = Result<(
+            Box<UserId>,
+            u64,
+            Raw<ruma::events::AnySyncEphemeralRoomEvent>,
+        )>,
+    > + 'a {
         let mut prefix = room_id.as_bytes().to_vec();
         prefix.push(0xff);
         let prefix2 = prefix.clone();
@@ -92,7 +97,7 @@ pub fn readreceipts_since<'a>(
                 let count =
                     utils::u64_from_bytes(&k[prefix.len()..prefix.len() + mem::size_of::<u64>()])
                         .map_err(|_| Error::bad_database("Invalid readreceiptid count in db."))?;
-                let user_id = UserId::try_from(
+                let user_id = Box::<UserId>::try_from(
                     utils::string_from_bytes(&k[prefix.len() + mem::size_of::<u64>() + 1..])
                         .map_err(|_| {
                             Error::bad_database("Invalid readreceiptid userid bytes in db.")
@@ -309,7 +314,7 @@ pub fn typings_all(
             .typingid_userid
             .scan_prefix(prefix)
             .map(|(_, user_id)| {
-                UserId::try_from(utils::string_from_bytes(&user_id).map_err(|_| {
+                Box::<UserId>::try_from(utils::string_from_bytes(&user_id).map_err(|_| {
                     Error::bad_database("User ID in typingid_userid is invalid unicode.")
                 })?)
                 .map_err(|_| Error::bad_database("User ID in typingid_userid is invalid."))
@@ -449,7 +454,7 @@ fn _presence_maintain(
         {
             // Send new presence events to set the user offline
             let count = globals.next_count()?.to_be_bytes();
-            let user_id = utils::string_from_bytes(&user_id_bytes)
+            let user_id: Box<_> = utils::string_from_bytes(&user_id_bytes)
                 .map_err(|_| {
                     Error::bad_database("Invalid UserId bytes in userid_lastpresenceupdate.")
                 })?
@@ -475,7 +480,7 @@ fn _presence_maintain(
                             presence: PresenceState::Offline,
                             status_msg: None,
                         },
-                        sender: user_id.clone(),
+                        sender: user_id.to_owned(),
                     })
                     .expect("PresenceEvent can be serialized"),
                 )?;
@@ -498,7 +503,7 @@ pub fn presence_since(
         since: u64,
         _rooms: &super::Rooms,
         _globals: &super::super::globals::Globals,
-    ) -> Result<HashMap<UserId, PresenceEvent>> {
+    ) -> Result<HashMap<Box<UserId>, PresenceEvent>> {
         //self.presence_maintain(rooms, globals)?;
 
         let mut prefix = room_id.as_bytes().to_vec();
@@ -513,7 +518,7 @@ pub fn presence_since(
             .iter_from(&*first_possible_edu, false)
             .take_while(|(key, _)| key.starts_with(&prefix))
         {
-            let user_id = UserId::try_from(
+            let user_id = Box::<UserId>::try_from(
                 utils::string_from_bytes(
                     key.rsplit(|&b| b == 0xff)
                         .next()
diff --git a/src/database/sending.rs b/src/database/sending.rs
index bf0cc2c16f9b7c66292725595506f2131724ca56..c27b57316e16c5e7bedb94a56a5ad121ddd27f37 100644
--- a/src/database/sending.rs
+++ b/src/database/sending.rs
@@ -397,7 +397,7 @@ pub fn select_edus(db: &Database, server: &ServerName) -> Result<(Vec<Vec<u8>>,
             // Because synapse resyncs, we can just insert dummy data
             let edu = Edu::DeviceListUpdate(DeviceListUpdateContent {
                 user_id,
-                device_id: device_id!("dummy"),
+                device_id: device_id!("dummy").to_owned(),
                 device_display_name: Some("Dummy".to_owned()),
                 stream_id: uint!(1),
                 prev_id: Vec::new(),
@@ -584,7 +584,7 @@ async fn handle_events(
                     }
 
                     let userid =
-                        UserId::try_from(utils::string_from_bytes(user).map_err(|_| {
+                        Box::<UserId>::try_from(utils::string_from_bytes(user).map_err(|_| {
                             (
                                 kind.clone(),
                                 Error::bad_database("Invalid push user string in db."),
diff --git a/src/database/users.rs b/src/database/users.rs
index d0da0714e5662105e9e9cb4eeb29b8fe2ecff2db..4a0847228b4263a13e8efff6ef033a46d8f181f9 100644
--- a/src/database/users.rs
+++ b/src/database/users.rs
@@ -63,11 +63,11 @@ pub fn is_admin(
         globals: &super::globals::Globals,
     ) -> Result<bool> {
         let admin_room_alias_id =
-            RoomAliasId::try_from(format!("#admins:{}", globals.server_name()))
+            Box::<RoomAliasId>::try_from(format!("#admins:{}", globals.server_name()))
                 .map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, "Invalid alias."))?;
         let admin_room_id = rooms.id_from_alias(&admin_room_alias_id)?.unwrap();
 
-        Ok(rooms.is_joined(user_id, &admin_room_id)?)
+        rooms.is_joined(user_id, &admin_room_id)
     }
 
     /// Create a new user account on this homeserver.
@@ -85,7 +85,7 @@ pub fn count(&self) -> Result<usize> {
 
     /// Find out which user an access token belongs to.
     #[tracing::instrument(skip(self, token))]
-    pub fn find_from_token(&self, token: &str) -> Result<Option<(UserId, String)>> {
+    pub fn find_from_token(&self, token: &str) -> Result<Option<(Box<UserId>, String)>> {
         self.token_userdeviceid
             .get(token.as_bytes())?
             .map_or(Ok(None), |bytes| {
@@ -98,9 +98,11 @@ pub fn find_from_token(&self, token: &str) -> Result<Option<(UserId, String)>> {
                 })?;
 
                 Ok(Some((
-                    UserId::try_from(utils::string_from_bytes(user_bytes).map_err(|_| {
-                        Error::bad_database("User ID in token_userdeviceid is invalid unicode.")
-                    })?)
+                    Box::<UserId>::try_from(utils::string_from_bytes(user_bytes).map_err(
+                        |_| {
+                            Error::bad_database("User ID in token_userdeviceid is invalid unicode.")
+                        },
+                    )?)
                     .map_err(|_| {
                         Error::bad_database("User ID in token_userdeviceid is invalid.")
                     })?,
@@ -113,9 +115,9 @@ pub fn find_from_token(&self, token: &str) -> Result<Option<(UserId, String)>> {
 
     /// Returns an iterator over all users on this homeserver.
     #[tracing::instrument(skip(self))]
-    pub fn iter(&self) -> impl Iterator<Item = Result<UserId>> + '_ {
+    pub fn iter(&self) -> impl Iterator<Item = Result<Box<UserId>>> + '_ {
         self.userid_password.iter().map(|(bytes, _)| {
-            UserId::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
+            Box::<UserId>::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
                 Error::bad_database("User ID in userid_password is invalid unicode.")
             })?)
             .map_err(|_| Error::bad_database("User ID in userid_password is invalid."))
@@ -181,20 +183,21 @@ pub fn set_displayname(&self, user_id: &UserId, displayname: Option<String>) ->
 
     /// Get the avatar_url of a user.
     #[tracing::instrument(skip(self, user_id))]
-    pub fn avatar_url(&self, user_id: &UserId) -> Result<Option<MxcUri>> {
+    pub fn avatar_url(&self, user_id: &UserId) -> Result<Option<Box<MxcUri>>> {
         self.userid_avatarurl
             .get(user_id.as_bytes())?
             .map(|bytes| {
                 let s = utils::string_from_bytes(&bytes)
                     .map_err(|_| Error::bad_database("Avatar URL in db is invalid."))?;
-                MxcUri::try_from(s).map_err(|_| Error::bad_database("Avatar URL in db is invalid."))
+                Box::<MxcUri>::try_from(s)
+                    .map_err(|_| Error::bad_database("Avatar URL in db is invalid."))
             })
             .transpose()
     }
 
     /// Sets a new avatar_url or removes it if avatar_url is None.
     #[tracing::instrument(skip(self, user_id, avatar_url))]
-    pub fn set_avatar_url(&self, user_id: &UserId, avatar_url: Option<MxcUri>) -> Result<()> {
+    pub fn set_avatar_url(&self, user_id: &UserId, avatar_url: Option<Box<MxcUri>>) -> Result<()> {
         if let Some(avatar_url) = avatar_url {
             self.userid_avatarurl
                 .insert(user_id.as_bytes(), avatar_url.to_string().as_bytes())?;
@@ -409,7 +412,7 @@ pub fn take_one_time_key(
         device_id: &DeviceId,
         key_algorithm: &DeviceKeyAlgorithm,
         globals: &super::globals::Globals,
-    ) -> Result<Option<(DeviceKeyId, OneTimeKey)>> {
+    ) -> Result<Option<(Box<DeviceKeyId>, OneTimeKey)>> {
         let mut prefix = user_id.as_bytes().to_vec();
         prefix.push(0xff);
         prefix.extend_from_slice(device_id.as_bytes());
@@ -459,7 +462,7 @@ pub fn count_one_time_keys(
                 .scan_prefix(userdeviceid)
                 .map(|(bytes, _)| {
                     Ok::<_, Error>(
-                        serde_json::from_slice::<DeviceKeyId>(
+                        serde_json::from_slice::<Box<DeviceKeyId>>(
                             &*bytes.rsplit(|&b| b == 0xff).next().ok_or_else(|| {
                                 Error::bad_database("OneTimeKey ID in db is invalid.")
                             })?,
@@ -632,7 +635,7 @@ pub fn sign_key(
             .ok_or_else(|| Error::bad_database("key in keyid_key has no signatures field."))?
             .as_object_mut()
             .ok_or_else(|| Error::bad_database("key in keyid_key has invalid signatures field."))?
-            .entry(sender_id.clone())
+            .entry(sender_id.to_owned())
             .or_insert_with(|| serde_json::Map::new().into());
 
         signatures
@@ -657,7 +660,7 @@ pub fn keys_changed<'a>(
         user_or_room_id: &str,
         from: u64,
         to: Option<u64>,
-    ) -> impl Iterator<Item = Result<UserId>> + 'a {
+    ) -> impl Iterator<Item = Result<Box<UserId>>> + 'a {
         let mut prefix = user_or_room_id.as_bytes().to_vec();
         prefix.push(0xff);
 
@@ -683,7 +686,7 @@ pub fn keys_changed<'a>(
                     }
             })
             .map(|(_, bytes)| {
-                UserId::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
+                Box::<UserId>::try_from(utils::string_from_bytes(&bytes).map_err(|_| {
                     Error::bad_database("User ID in devicekeychangeid_userid is invalid unicode.")
                 })?)
                 .map_err(|_| Error::bad_database("User ID in devicekeychangeid_userid is invalid."))
diff --git a/src/pdu.rs b/src/pdu.rs
index 0f99f43bf8dd653425a26c2f86e34f9ea65a6512..3c955976113036978e45f4d062fecdbefb49be4e 100644
--- a/src/pdu.rs
+++ b/src/pdu.rs
@@ -13,7 +13,7 @@
     json,
     value::{to_raw_value, RawValue as RawJsonValue},
 };
-use std::{cmp::Ordering, collections::BTreeMap, convert::TryFrom};
+use std::{cmp::Ordering, collections::BTreeMap, convert::TryFrom, ops::Deref};
 use tracing::warn;
 
 /// Content hashes of a PDU.
@@ -25,20 +25,20 @@ pub struct EventHash {
 
 #[derive(Clone, Deserialize, Serialize, Debug)]
 pub struct PduEvent {
-    pub event_id: EventId,
-    pub room_id: RoomId,
-    pub sender: UserId,
+    pub event_id: Box<EventId>,
+    pub room_id: Box<RoomId>,
+    pub sender: Box<UserId>,
     pub origin_server_ts: UInt,
     #[serde(rename = "type")]
     pub kind: EventType,
     pub content: Box<RawJsonValue>,
     #[serde(skip_serializing_if = "Option::is_none")]
     pub state_key: Option<String>,
-    pub prev_events: Vec<EventId>,
+    pub prev_events: Vec<Box<EventId>>,
     pub depth: UInt,
-    pub auth_events: Vec<EventId>,
+    pub auth_events: Vec<Box<EventId>>,
     #[serde(skip_serializing_if = "Option::is_none")]
-    pub redacts: Option<EventId>,
+    pub redacts: Option<Box<EventId>>,
     #[serde(default, skip_serializing_if = "Option::is_none")]
     pub unsigned: Option<Box<RawJsonValue>>,
     pub hashes: EventHash,
@@ -295,15 +295,15 @@ fn state_key(&self) -> Option<&str> {
     }
 
     fn prev_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_> {
-        Box::new(self.prev_events.iter())
+        Box::new(self.prev_events.iter().map(Deref::deref))
     }
 
     fn auth_events(&self) -> Box<dyn DoubleEndedIterator<Item = &EventId> + '_> {
-        Box::new(self.auth_events.iter())
+        Box::new(self.auth_events.iter().map(Deref::deref))
     }
 
     fn redacts(&self) -> Option<&EventId> {
-        self.redacts.as_ref()
+        self.redacts.as_deref()
     }
 }
 
@@ -331,16 +331,16 @@ fn cmp(&self, other: &Self) -> Ordering {
 /// Returns a tuple of the new `EventId` and the PDU as a `BTreeMap<String, CanonicalJsonValue>`.
 pub(crate) fn gen_event_id_canonical_json(
     pdu: &RawJsonValue,
-) -> crate::Result<(EventId, CanonicalJsonObject)> {
+) -> crate::Result<(Box<EventId>, CanonicalJsonObject)> {
     let value = serde_json::from_str(pdu.get()).map_err(|e| {
         warn!("Error parsing incoming event {:?}: {:?}", pdu, e);
         Error::BadServerResponse("Invalid PDU in server response")
     })?;
 
-    let event_id = EventId::try_from(&*format!(
+    let event_id = Box::<EventId>::try_from(&*format!(
         "${}",
         // Anything higher than version3 behaves the same
-        ruma::signatures::reference_hash(&value, &RoomVersionId::Version6)
+        ruma::signatures::reference_hash(&value, &RoomVersionId::V6)
             .expect("ruma can calculate reference hashes")
     ))
     .expect("ruma's reference hashes are valid event ids");
@@ -356,7 +356,7 @@ pub struct PduBuilder {
     pub content: Box<RawJsonValue>,
     pub unsigned: Option<BTreeMap<String, serde_json::Value>>,
     pub state_key: Option<String>,
-    pub redacts: Option<EventId>,
+    pub redacts: Option<Box<EventId>>,
 }
 
 /// Direct conversion prevents loss of the empty `state_key` that ruma requires.
diff --git a/src/ruma_wrapper.rs b/src/ruma_wrapper.rs
index 03c115cdaff0995d4f3b46f02667a258e2122bc3..2cff2f5a9f7242d4b900bea99ac354ed9dc18cb9 100644
--- a/src/ruma_wrapper.rs
+++ b/src/ruma_wrapper.rs
@@ -29,7 +29,7 @@
 /// first.
 pub struct Ruma<T: Outgoing> {
     pub body: T::Incoming,
-    pub sender_user: Option<UserId>,
+    pub sender_user: Option<Box<UserId>>,
     pub sender_device: Option<Box<DeviceId>>,
     pub sender_servername: Option<Box<ServerName>>,
     // This is None when body is not a valid string
@@ -86,7 +86,7 @@ async fn from_data(
                 registration
                     .get("as_token")
                     .and_then(|as_token| as_token.as_str())
-                    .map_or(false, |as_token| token.as_deref() == Some(as_token))
+                    .map_or(false, |as_token| token == Some(as_token))
             }) {
             match metadata.authentication {
                 AuthScheme::AccessToken | AuthScheme::QueryOnlyAccessToken => {
@@ -103,7 +103,7 @@ async fn from_data(
                             .unwrap()
                         },
                         |string| {
-                            UserId::try_from(string.expect("parsing to string always works"))
+                            Box::<UserId>::try_from(string.expect("parsing to string always works"))
                                 .unwrap()
                         },
                     );
diff --git a/src/server_server.rs b/src/server_server.rs
index 482edf0f6a6935a607e6f61139a4881107abd1e9..ec5bc345aed6aeb8a2dc493941e8311d0e26cd24 100644
--- a/src/server_server.rs
+++ b/src/server_server.rs
@@ -552,7 +552,7 @@ pub fn get_server_keys_route(db: DatabaseGuard) -> Json<String> {
 
     let mut verify_keys = BTreeMap::new();
     verify_keys.insert(
-        ServerSigningKeyId::try_from(
+        Box::<ServerSigningKeyId>::try_from(
             format!("ed25519:{}", db.globals.keypair().version()).as_str(),
         )
         .expect("found invalid server signing keys in DB"),
@@ -736,7 +736,7 @@ pub async fn send_transaction_message_route(
         // 0. Check the server is in the room
         let room_id = match value
             .get("room_id")
-            .and_then(|id| RoomId::try_from(id.as_str()?).ok())
+            .and_then(|id| Box::<RoomId>::try_from(id.as_str()?).ok())
         {
             Some(id) => id,
             None => {
@@ -1003,11 +1003,10 @@ pub(crate) async fn handle_incoming_pdu<'a>(
     // 9. Fetch any missing prev events doing all checks listed here starting at 1. These are timeline events
     let mut graph = HashMap::new();
     let mut eventid_info = HashMap::new();
-    let mut todo_outlier_stack: Vec<_> = incoming_pdu
+    let mut todo_outlier_stack: Vec<Arc<EventId>> = incoming_pdu
         .prev_events
         .iter()
-        .cloned()
-        .map(Arc::new)
+        .map(|x| Arc::from(&**x))
         .collect();
 
     let mut amount = 0;
@@ -1027,7 +1026,7 @@ pub(crate) async fn handle_incoming_pdu<'a>(
             if amount > 100 {
                 // Max limit reached
                 warn!("Max prev event limit reached!");
-                graph.insert((*prev_event_id).clone(), HashSet::new());
+                graph.insert((*prev_event_id).to_owned(), HashSet::new());
                 continue;
             }
 
@@ -1038,27 +1037,27 @@ pub(crate) async fn handle_incoming_pdu<'a>(
                     amount += 1;
                     for prev_prev in &pdu.prev_events {
                         if !graph.contains_key(prev_prev) {
-                            todo_outlier_stack.push(dbg!(Arc::new(prev_prev.clone())));
+                            todo_outlier_stack.push(dbg!(Arc::from(&**prev_prev)));
                         }
                     }
 
                     graph.insert(
-                        (*prev_event_id).clone(),
+                        (*prev_event_id).to_owned(),
                         pdu.prev_events.iter().cloned().collect(),
                     );
                 } else {
                     // Time based check failed
-                    graph.insert((*prev_event_id).clone(), HashSet::new());
+                    graph.insert((*prev_event_id).to_owned(), HashSet::new());
                 }
 
                 eventid_info.insert(prev_event_id.clone(), (pdu, json));
             } else {
                 // Get json failed
-                graph.insert((*prev_event_id).clone(), HashSet::new());
+                graph.insert((*prev_event_id).to_owned(), HashSet::new());
             }
         } else {
             // Fetch and handle failed
-            graph.insert((*prev_event_id).clone(), HashSet::new());
+            graph.insert((*prev_event_id).to_owned(), HashSet::new());
         }
     }
 
@@ -1074,7 +1073,6 @@ pub(crate) async fn handle_incoming_pdu<'a>(
                     .get(event_id)
                     .map_or_else(|| uint!(0), |info| info.0.origin_server_ts),
             ),
-            ruma::event_id!("$notimportant"),
         ))
     })
     .map_err(|_| "Error sorting prev events".to_owned())?;
@@ -1084,7 +1082,7 @@ pub(crate) async fn handle_incoming_pdu<'a>(
         if errors >= 5 {
             break;
         }
-        if let Some((pdu, json)) = eventid_info.remove(&prev_id) {
+        if let Some((pdu, json)) = eventid_info.remove(&*prev_id) {
             if pdu.origin_server_ts < first_pdu_in_room.origin_server_ts {
                 continue;
             }
@@ -1200,8 +1198,7 @@ fn handle_outlier_pdu<'a>(
             &incoming_pdu
                 .auth_events
                 .iter()
-                .cloned()
-                .map(Arc::new)
+                .map(|x| Arc::from(&**x))
                 .collect::<Vec<_>>(),
             create_event,
             room_id,
@@ -1331,7 +1328,7 @@ async fn upgrade_outlier_to_timeline_pdu(
     let mut state_at_incoming_event = None;
 
     if incoming_pdu.prev_events.len() == 1 {
-        let prev_event = &incoming_pdu.prev_events[0];
+        let prev_event = &*incoming_pdu.prev_events[0];
         let prev_event_sstatehash = db
             .rooms
             .pdu_shortstatehash(prev_event)
@@ -1353,7 +1350,7 @@ async fn upgrade_outlier_to_timeline_pdu(
                     .get_or_create_shortstatekey(&prev_pdu.kind, state_key, &db.globals)
                     .map_err(|_| "Failed to create shortstatekey.".to_owned())?;
 
-                state.insert(shortstatekey, Arc::new(prev_event.clone()));
+                state.insert(shortstatekey, Arc::from(prev_event));
                 // Now it's the state after the pdu
             }
 
@@ -1397,7 +1394,7 @@ async fn upgrade_outlier_to_timeline_pdu(
                         .rooms
                         .get_or_create_shortstatekey(&prev_event.kind, state_key, &db.globals)
                         .map_err(|_| "Failed to create shortstatekey.".to_owned())?;
-                    leaf_state.insert(shortstatekey, Arc::new(prev_event.event_id.clone()));
+                    leaf_state.insert(shortstatekey, Arc::from(&*prev_event.event_id));
                     // Now it's the state after the pdu
                 }
 
@@ -1410,14 +1407,14 @@ async fn upgrade_outlier_to_timeline_pdu(
                         .get_statekey_from_short(k)
                         .map_err(|_| "Failed to get_statekey_from_short.".to_owned())?;
 
-                    state.insert(k, (*id).clone());
+                    state.insert(k, (*id).to_owned());
                     starting_events.push(id);
                 }
 
                 auth_chain_sets.push(
                     get_auth_chain(room_id, starting_events, db)
                         .map_err(|_| "Failed to load auth chain.".to_owned())?
-                        .map(|event_id| (*event_id).clone())
+                        .map(|event_id| (*event_id).to_owned())
                         .collect(),
                 );
 
@@ -1444,7 +1441,7 @@ async fn upgrade_outlier_to_timeline_pdu(
                                 .rooms
                                 .get_or_create_shortstatekey(&event_type, &state_key, &db.globals)
                                 .map_err(|_| "Failed to get_or_create_shortstatekey".to_owned())?;
-                            Ok((shortstatekey, Arc::new(event_id)))
+                            Ok((shortstatekey, Arc::from(event_id)))
                         })
                         .collect::<Result<_, String>>()?,
                 ),
@@ -1479,8 +1476,7 @@ async fn upgrade_outlier_to_timeline_pdu(
                     origin,
                     &res.pdu_ids
                         .iter()
-                        .cloned()
-                        .map(Arc::new)
+                        .map(|x| Arc::from(&**x))
                         .collect::<Vec<_>>(),
                     create_event,
                     room_id,
@@ -1488,7 +1484,7 @@ async fn upgrade_outlier_to_timeline_pdu(
                 )
                 .await;
 
-                let mut state = BTreeMap::new();
+                let mut state: BTreeMap<_, Arc<EventId>> = BTreeMap::new();
                 for (pdu, _) in state_vec {
                     let state_key = pdu
                         .state_key
@@ -1502,7 +1498,7 @@ async fn upgrade_outlier_to_timeline_pdu(
 
                     match state.entry(shortstatekey) {
                         btree_map::Entry::Vacant(v) => {
-                            v.insert(Arc::new(pdu.event_id.clone()));
+                            v.insert(Arc::from(&*pdu.event_id));
                         }
                         btree_map::Entry::Occupied(_) => return Err(
                             "State event's type and state_key combination exists multiple times."
@@ -1577,7 +1573,7 @@ async fn upgrade_outlier_to_timeline_pdu(
             .roomid_mutex_state
             .write()
             .unwrap()
-            .entry(room_id.clone())
+            .entry(room_id.to_owned())
             .or_default(),
     );
     let state_lock = mutex_state.lock().await;
@@ -1715,7 +1711,7 @@ async fn upgrade_outlier_to_timeline_pdu(
                     .rooms
                     .get_or_create_shortstatekey(&leaf_pdu.kind, state_key, &db.globals)
                     .map_err(|_| "Failed to create shortstatekey.".to_owned())?;
-                leaf_state.insert(shortstatekey, Arc::new(leaf_pdu.event_id.clone()));
+                leaf_state.insert(shortstatekey, Arc::from(&*leaf_pdu.event_id));
                 // Now it's the state after the pdu
             }
 
@@ -1730,7 +1726,7 @@ async fn upgrade_outlier_to_timeline_pdu(
                 .get_or_create_shortstatekey(&incoming_pdu.kind, state_key, &db.globals)
                 .map_err(|_| "Failed to create shortstatekey.".to_owned())?;
 
-            state_after.insert(shortstatekey, Arc::new(incoming_pdu.event_id.clone()));
+            state_after.insert(shortstatekey, Arc::from(&*incoming_pdu.event_id));
         }
         fork_states.push(state_after);
 
@@ -1762,7 +1758,7 @@ async fn upgrade_outlier_to_timeline_pdu(
                         db,
                     )
                     .map_err(|_| "Failed to load auth chain.".to_owned())?
-                    .map(|event_id| (*event_id).clone())
+                    .map(|event_id| (*event_id).to_owned())
                     .collect(),
                 );
             }
@@ -1774,7 +1770,7 @@ async fn upgrade_outlier_to_timeline_pdu(
                         .map(|(k, id)| {
                             db.rooms
                                 .get_statekey_from_short(k)
-                                .map(|k| (k, (*id).clone()))
+                                .map(|k| (k, (*id).to_owned()))
                         })
                         .collect::<Result<StateMap<_>>>()
                 })
@@ -1874,7 +1870,8 @@ pub(crate) fn fetch_and_handle_outliers<'a>(
 
         let mut pdus = vec![];
         for id in events {
-            if let Some((time, tries)) = db.globals.bad_event_ratelimiter.read().unwrap().get(id) {
+            if let Some((time, tries)) = db.globals.bad_event_ratelimiter.read().unwrap().get(&**id)
+            {
                 // Exponential backoff
                 let mut min_elapsed_duration = Duration::from_secs(5 * 60) * (*tries) * (*tries);
                 if min_elapsed_duration > Duration::from_secs(60 * 60 * 24) {
@@ -1914,7 +1911,7 @@ pub(crate) fn fetch_and_handle_outliers<'a>(
                                 match crate::pdu::gen_event_id_canonical_json(&res.pdu) {
                                     Ok(t) => t,
                                     Err(_) => {
-                                        back_off((**id).clone());
+                                        back_off((**id).to_owned());
                                         continue;
                                     }
                                 };
@@ -1939,14 +1936,14 @@ pub(crate) fn fetch_and_handle_outliers<'a>(
                                 Ok((pdu, json)) => (pdu, Some(json)),
                                 Err(e) => {
                                     warn!("Authentication of event {} failed: {:?}", id, e);
-                                    back_off((**id).clone());
+                                    back_off((**id).to_owned());
                                     continue;
                                 }
                             }
                         }
                         Err(_) => {
                             warn!("Failed to fetch event: {}", id);
-                            back_off((**id).clone());
+                            back_off((**id).to_owned());
                             continue;
                         }
                     }
@@ -2128,7 +2125,7 @@ fn append_incoming_pdu(
     db: &Database,
     pdu: &PduEvent,
     pdu_json: CanonicalJsonObject,
-    new_room_leaves: HashSet<EventId>,
+    new_room_leaves: HashSet<Box<EventId>>,
     state_ids_compressed: HashSet<CompressedStateEvent>,
     soft_fail: bool,
     _mutex_lock: &MutexGuard<'_, ()>, // Take mutex guard to make sure users get the room mutex
@@ -2298,13 +2295,13 @@ fn get_auth_chain_inner(
     event_id: &EventId,
     db: &Database,
 ) -> Result<HashSet<u64>> {
-    let mut todo = vec![event_id.clone()];
+    let mut todo = vec![event_id.to_owned()];
     let mut found = HashSet::new();
 
     while let Some(event_id) = todo.pop() {
         match db.rooms.get_pdu(&event_id) {
             Ok(Some(pdu)) => {
-                if &pdu.room_id != room_id {
+                if pdu.room_id != room_id {
                     return Err(Error::BadRequest(ErrorKind::Forbidden, "Evil event in db"));
                 }
                 for auth_event in &pdu.auth_events {
@@ -2314,7 +2311,7 @@ fn get_auth_chain_inner(
 
                     if !found.contains(&sauthevent) {
                         found.insert(sauthevent);
-                        todo.push(auth_event.clone());
+                        todo.push(auth_event.to_owned());
                     }
                 }
             }
@@ -2363,7 +2360,7 @@ pub fn get_event_route(
         .and_then(|val| val.as_str())
         .ok_or_else(|| Error::bad_database("Invalid event in database"))?;
 
-    let room_id = RoomId::try_from(room_id_str)
+    let room_id = Box::<RoomId>::try_from(room_id_str)
         .map_err(|_| Error::bad_database("Invalid room id field in event in database"))?;
 
     if !db.rooms.server_in_room(sender_servername, &room_id)? {
@@ -2417,7 +2414,7 @@ pub fn get_missing_events_route(
                 .and_then(|val| val.as_str())
                 .ok_or_else(|| Error::bad_database("Invalid event in database"))?;
 
-            let event_room_id = RoomId::try_from(room_id_str)
+            let event_room_id = Box::<RoomId>::try_from(room_id_str)
                 .map_err(|_| Error::bad_database("Invalid room id field in event in database"))?;
 
             if event_room_id != body.room_id {
@@ -2436,7 +2433,7 @@ pub fn get_missing_events_route(
                 continue;
             }
             queued_events.extend_from_slice(
-                &serde_json::from_value::<Vec<EventId>>(
+                &serde_json::from_value::<Vec<Box<EventId>>>(
                     serde_json::to_value(pdu.get("prev_events").cloned().ok_or_else(|| {
                         Error::bad_database("Event in db has no prev_events field.")
                     })?)
@@ -2485,14 +2482,14 @@ pub fn get_event_authorization_route(
         .and_then(|val| val.as_str())
         .ok_or_else(|| Error::bad_database("Invalid event in database"))?;
 
-    let room_id = RoomId::try_from(room_id_str)
+    let room_id = Box::<RoomId>::try_from(room_id_str)
         .map_err(|_| Error::bad_database("Invalid room id field in event in database"))?;
 
     if !db.rooms.server_in_room(sender_servername, &room_id)? {
         return Err(Error::BadRequest(ErrorKind::NotFound, "Event not found."));
     }
 
-    let auth_chain_ids = get_auth_chain(&room_id, vec![Arc::new(body.event_id.clone())], &db)?;
+    let auth_chain_ids = get_auth_chain(&room_id, vec![Arc::from(&*body.event_id)], &db)?;
 
     Ok(get_event_authorization::v1::Response {
         auth_chain: auth_chain_ids
@@ -2550,7 +2547,7 @@ pub fn get_room_state_route(
         })
         .collect();
 
-    let auth_chain_ids = get_auth_chain(&body.room_id, vec![Arc::new(body.event_id.clone())], &db)?;
+    let auth_chain_ids = get_auth_chain(&body.room_id, vec![Arc::from(&*body.event_id)], &db)?;
 
     Ok(get_room_state::v1::Response {
         auth_chain: auth_chain_ids
@@ -2606,13 +2603,13 @@ pub fn get_room_state_ids_route(
         .rooms
         .state_full_ids(shortstatehash)?
         .into_iter()
-        .map(|(_, id)| (*id).clone())
+        .map(|(_, id)| (*id).to_owned())
         .collect();
 
-    let auth_chain_ids = get_auth_chain(&body.room_id, vec![Arc::new(body.event_id.clone())], &db)?;
+    let auth_chain_ids = get_auth_chain(&body.room_id, vec![Arc::from(&*body.event_id)], &db)?;
 
     Ok(get_room_state_ids::v1::Response {
-        auth_chain_ids: auth_chain_ids.map(|id| (*id).clone()).collect(),
+        auth_chain_ids: auth_chain_ids.map(|id| (*id).to_owned()).collect(),
         pdu_ids,
     }
     .into())
@@ -2671,9 +2668,8 @@ pub fn create_join_event_template_route(
     };
 
     // If there was no create event yet, assume we are creating a version 6 room right now
-    let room_version_id = create_event_content.map_or(RoomVersionId::Version6, |create_event| {
-        create_event.room_version
-    });
+    let room_version_id =
+        create_event_content.map_or(RoomVersionId::V6, |create_event| create_event.room_version);
     let room_version = RoomVersion::new(&room_version_id).expect("room version is supported");
 
     if !body.ver.contains(&room_version_id) {
@@ -2726,7 +2722,7 @@ pub fn create_join_event_template_route(
     }
 
     let pdu = PduEvent {
-        event_id: ruma::event_id!("$thiswillbefilledinlater"),
+        event_id: ruma::event_id!("$thiswillbefilledinlater").to_owned(),
         room_id: body.room_id.clone(),
         sender: body.user_id.clone(),
         origin_server_ts: utils::millis_since_unix_epoch()
@@ -2838,7 +2834,7 @@ async fn create_join_event(
             .roomid_mutex_federation
             .write()
             .unwrap()
-            .entry(room_id.clone())
+            .entry(room_id.to_owned())
             .or_default(),
     );
     let mutex_lock = mutex.lock().await;
@@ -2937,8 +2933,7 @@ pub async fn create_invite_route(
         return Err(Error::bad_config("Federation is disabled."));
     }
 
-    if body.room_version != RoomVersionId::Version5 && body.room_version != RoomVersionId::Version6
-    {
+    if body.room_version != RoomVersionId::V5 && body.room_version != RoomVersionId::V6 {
         return Err(Error::BadRequest(
             ErrorKind::IncompatibleRoomVersion {
                 room_version: body.room_version.clone(),
@@ -2959,7 +2954,7 @@ pub async fn create_invite_route(
     .map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, "Failed to sign event."))?;
 
     // Generate event id
-    let event_id = EventId::try_from(&*format!(
+    let event_id = Box::<EventId>::try_from(&*format!(
         "${}",
         ruma::signatures::reference_hash(&signed_event, &body.room_version)
             .expect("ruma can calculate reference hashes")
@@ -2972,7 +2967,7 @@ pub async fn create_invite_route(
         CanonicalJsonValue::String(event_id.into()),
     );
 
-    let sender = serde_json::from_value(
+    let sender: Box<_> = serde_json::from_value(
         signed_event
             .get("sender")
             .ok_or(Error::BadRequest(
@@ -2984,7 +2979,7 @@ pub async fn create_invite_route(
     )
     .map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, "sender is not a user id."))?;
 
-    let invited_user = serde_json::from_value(
+    let invited_user: Box<_> = serde_json::from_value(
         signed_event
             .get("state_key")
             .ok_or(Error::BadRequest(
@@ -3263,7 +3258,7 @@ pub(crate) async fn fetch_required_signing_keys(
 // the PDUs and either cache the key or add it to the list that needs to be retrieved.
 fn get_server_keys_from_cache(
     pdu: &RawJsonValue,
-    servers: &mut BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, QueryCriteria>>,
+    servers: &mut BTreeMap<Box<ServerName>, BTreeMap<Box<ServerSigningKeyId>, QueryCriteria>>,
     room_version: &RoomVersionId,
     pub_key_map: &mut RwLockWriteGuard<'_, BTreeMap<String, BTreeMap<String, String>>>,
     db: &Database,
@@ -3273,7 +3268,7 @@ fn get_server_keys_from_cache(
         Error::BadServerResponse("Invalid PDU in server response")
     })?;
 
-    let event_id = EventId::try_from(&*format!(
+    let event_id = Box::<EventId>::try_from(&*format!(
         "${}",
         ruma::signatures::reference_hash(&value, room_version)
             .expect("ruma can calculate reference hashes")
@@ -3353,7 +3348,7 @@ pub(crate) async fn fetch_join_signing_keys(
     pub_key_map: &RwLock<BTreeMap<String, BTreeMap<String, String>>>,
     db: &Database,
 ) -> Result<()> {
-    let mut servers: BTreeMap<Box<ServerName>, BTreeMap<ServerSigningKeyId, QueryCriteria>> =
+    let mut servers: BTreeMap<Box<ServerName>, BTreeMap<Box<ServerSigningKeyId>, QueryCriteria>> =
         BTreeMap::new();
 
     {
@@ -3387,10 +3382,6 @@ pub(crate) async fn fetch_join_signing_keys(
                 server,
                 get_remote_server_keys_batch::v2::Request {
                     server_keys: servers.clone(),
-                    minimum_valid_until_ts: MilliSecondsSinceUnixEpoch::from_system_time(
-                        SystemTime::now() + Duration::from_secs(60),
-                    )
-                    .expect("time is valid"),
                 },
             )
             .await