diff --git a/Cargo.lock b/Cargo.lock
index b5be6aaa..4734f804 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -215,21 +215,11 @@ dependencies = [
  "trust-dns-resolver",
 ]
 
-[[package]]
-name = "console_error_panic_hook"
-version = "0.1.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
-dependencies = [
- "cfg-if 0.1.10",
- "wasm-bindgen",
-]
-
 [[package]]
 name = "const_fn"
-version = "0.4.3"
+version = "0.4.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
+checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826"
 
 [[package]]
 name = "constant_time_eq"
@@ -631,9 +621,9 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
 
 [[package]]
 name = "heck"
-version = "0.3.1"
+version = "0.3.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
+checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
 dependencies = [
  "unicode-segmentation",
 ]
@@ -660,9 +650,9 @@ dependencies = [
 
 [[package]]
 name = "http"
-version = "0.2.1"
+version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9"
+checksum = "84129d298a6d57d246960ff8eb831ca4af3f96d29e2e28848dae275408658e26"
 dependencies = [
  "bytes",
  "fnv",
@@ -758,9 +748,9 @@ dependencies = [
 
 [[package]]
 name = "indexmap"
-version = "1.6.0"
+version = "1.6.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2"
+checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b"
 dependencies = [
  "autocfg",
  "hashbrown",
@@ -1035,9 +1025,9 @@ dependencies = [
 
 [[package]]
 name = "net2"
-version = "0.2.36"
+version = "0.2.37"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7cf75f38f16cb05ea017784dc6dbfd354f76c223dba37701734c4f5a9337d02"
+checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
 dependencies = [
  "cfg-if 0.1.10",
  "libc",
@@ -1109,12 +1099,12 @@ checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0"
 
 [[package]]
 name = "openssl"
-version = "0.10.30"
+version = "0.10.31"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4"
+checksum = "8d008f51b1acffa0d3450a68606e6a51c123012edaacb0f4e1426bd978869187"
 dependencies = [
  "bitflags",
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
  "foreign-types",
  "lazy_static",
  "libc",
@@ -1129,18 +1119,18 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
 
 [[package]]
 name = "openssl-src"
-version = "111.12.0+1.1.1h"
+version = "111.13.0+1.1.1i"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "858a4132194f8570a7ee9eb8629e85b23cbc4565f2d4a162e87556e5956abf61"
+checksum = "045e4dc48af57aad93d665885789b43222ae26f4886494da12d1ed58d309dcb6"
 dependencies = [
  "cc",
 ]
 
 [[package]]
 name = "openssl-sys"
-version = "0.9.58"
+version = "0.9.59"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de"
+checksum = "de52d8eabd217311538a39bba130d7dea1f1e118010fee7a033d966845e7d5fe"
 dependencies = [
  "autocfg",
  "cc",
@@ -1163,9 +1153,9 @@ dependencies = [
 
 [[package]]
 name = "parking_lot_core"
-version = "0.8.1"
+version = "0.8.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7c6d9b8427445284a09c55be860a15855ab580a417ccad9da88f5a06787ced0"
+checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272"
 dependencies = [
  "cfg-if 1.0.0",
  "instant",
@@ -1177,9 +1167,9 @@ dependencies = [
 
 [[package]]
 name = "paste"
-version = "1.0.3"
+version = "1.0.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7151b083b0664ed58ed669fcdd92f01c3d2fdbf10af4931a301474950b52bfa9"
+checksum = "c5d65c4d95931acda4498f675e332fcbdc9a06705cd07086c510e9b6009cd1c1"
 
 [[package]]
 name = "pear"
@@ -1276,9 +1266,9 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
 
 [[package]]
 name = "png"
-version = "0.16.7"
+version = "0.16.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dfe7f9f1c730833200b134370e1d5098964231af8450bce9b78ee3ab5278b970"
+checksum = "3c3287920cb847dee3de33d301c463fba14dda99db24214ddf93f83d3021f4c6"
 dependencies = [
  "bitflags",
  "crc32fast",
@@ -1343,9 +1333,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
 
 [[package]]
 name = "quote"
-version = "1.0.7"
+version = "1.0.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
+checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df"
 dependencies = [
  "proc-macro2",
 ]
@@ -1457,9 +1447,9 @@ dependencies = [
 
 [[package]]
 name = "reqwest"
-version = "0.10.9"
+version = "0.10.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fb15d6255c792356a0f578d8a645c677904dc02e862bebe2ecc18e0c01b9a0ce"
+checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c"
 dependencies = [
  "base64 0.13.0",
  "bytes",
@@ -1486,7 +1476,6 @@ dependencies = [
  "url",
  "wasm-bindgen",
  "wasm-bindgen-futures",
- "wasm-bindgen-test",
  "web-sys",
  "winreg 0.7.0",
 ]
@@ -1586,7 +1575,7 @@ dependencies = [
 [[package]]
 name = "ruma"
 version = "0.0.1"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "assign",
  "js_int",
@@ -1604,7 +1593,7 @@ dependencies = [
 [[package]]
 name = "ruma-api"
 version = "0.17.0-alpha.1"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "http",
  "percent-encoding",
@@ -1619,7 +1608,7 @@ dependencies = [
 [[package]]
 name = "ruma-api-macros"
 version = "0.17.0-alpha.1"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "proc-macro-crate",
  "proc-macro2",
@@ -1630,7 +1619,7 @@ dependencies = [
 [[package]]
 name = "ruma-appservice-api"
 version = "0.2.0-alpha.1"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "ruma-api",
  "ruma-common",
@@ -1644,7 +1633,7 @@ dependencies = [
 [[package]]
 name = "ruma-client-api"
 version = "0.10.0-alpha.1"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "assign",
  "http",
@@ -1663,7 +1652,7 @@ dependencies = [
 [[package]]
 name = "ruma-common"
 version = "0.2.0"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "js_int",
  "maplit",
@@ -1676,7 +1665,7 @@ dependencies = [
 [[package]]
 name = "ruma-events"
 version = "0.22.0-alpha.1"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "js_int",
  "ruma-common",
@@ -1690,7 +1679,7 @@ dependencies = [
 [[package]]
 name = "ruma-events-macros"
 version = "0.22.0-alpha.1"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "proc-macro-crate",
  "proc-macro2",
@@ -1701,7 +1690,7 @@ dependencies = [
 [[package]]
 name = "ruma-federation-api"
 version = "0.0.3"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "js_int",
  "ruma-api",
@@ -1716,7 +1705,7 @@ dependencies = [
 [[package]]
 name = "ruma-identifiers"
 version = "0.17.4"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "paste",
  "rand",
@@ -1730,7 +1719,7 @@ dependencies = [
 [[package]]
 name = "ruma-identifiers-macros"
 version = "0.17.4"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -1741,7 +1730,7 @@ dependencies = [
 [[package]]
 name = "ruma-identifiers-validation"
 version = "0.1.1"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "serde",
 ]
@@ -1749,7 +1738,7 @@ dependencies = [
 [[package]]
 name = "ruma-serde"
 version = "0.2.3"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "form_urlencoded",
  "itoa",
@@ -1762,7 +1751,7 @@ dependencies = [
 [[package]]
 name = "ruma-serde-macros"
 version = "0.2.0"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "proc-macro-crate",
  "proc-macro2",
@@ -1773,7 +1762,7 @@ dependencies = [
 [[package]]
 name = "ruma-signatures"
 version = "0.6.0-dev.1"
-source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
+source = "git+https://github.com/ruma/ruma?rev=45d01011554f9d07739e9a5edf5498d8ac16f273#45d01011554f9d07739e9a5edf5498d8ac16f273"
 dependencies = [
  "base64 0.12.3",
  "ring",
@@ -1839,12 +1828,6 @@ dependencies = [
  "winapi 0.3.9",
 ]
 
-[[package]]
-name = "scoped-tls"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
-
 [[package]]
 name = "scopeguard"
 version = "1.1.0"
@@ -1962,9 +1945,9 @@ checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
 
 [[package]]
 name = "signal-hook-registry"
-version = "1.2.2"
+version = "1.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab"
+checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6"
 dependencies = [
  "libc",
 ]
@@ -1999,13 +1982,12 @@ checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75"
 
 [[package]]
 name = "socket2"
-version = "0.3.17"
+version = "0.3.19"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902"
+checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
 dependencies = [
  "cfg-if 1.0.0",
  "libc",
- "redox_syscall",
  "winapi 0.3.9",
 ]
 
@@ -2033,7 +2015,7 @@ checksum = "3015a7d0a5fd5105c91c3710d42f9ccf0abfb287d62206484dcc67f9569a6483"
 [[package]]
 name = "state-res"
 version = "0.1.0"
-source = "git+https://github.com/ruma/state-res?branch=timo-spec-comp#a1c15253f0777baad251da47c3f2c016cfed6f7e"
+source = "git+https://github.com/ruma/state-res?branch=conflict#e2c5bb401263e1b2fde60313acf5fc4ef072c74d"
 dependencies = [
  "itertools",
  "maplit",
@@ -2116,9 +2098,9 @@ dependencies = [
 
 [[package]]
 name = "syn"
-version = "1.0.54"
+version = "1.0.55"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44"
+checksum = "a571a711dddd09019ccc628e1b17fe87c59b09d513c06c026877aa708334f37a"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -2223,9 +2205,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
 
 [[package]]
 name = "tokio"
-version = "0.2.23"
+version = "0.2.24"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a6d7ad61edd59bfcc7e80dababf0f4aed2e6d5e0ba1659356ae889752dfc12ff"
+checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48"
 dependencies = [
  "bytes",
  "fnv",
@@ -2293,9 +2275,9 @@ dependencies = [
 
 [[package]]
 name = "toml"
-version = "0.5.7"
+version = "0.5.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645"
+checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
 dependencies = [
  "serde",
 ]
@@ -2472,9 +2454,9 @@ dependencies = [
 
 [[package]]
 name = "vcpkg"
-version = "0.2.10"
+version = "0.2.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
+checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb"
 
 [[package]]
 name = "version_check"
@@ -2566,30 +2548,6 @@ version = "0.2.69"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158"
 
-[[package]]
-name = "wasm-bindgen-test"
-version = "0.3.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0355fa0c1f9b792a09b6dcb6a8be24d51e71e6d74972f9eb4a44c4c004d24a25"
-dependencies = [
- "console_error_panic_hook",
- "js-sys",
- "scoped-tls",
- "wasm-bindgen",
- "wasm-bindgen-futures",
- "wasm-bindgen-test-macro",
-]
-
-[[package]]
-name = "wasm-bindgen-test-macro"
-version = "0.3.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "27e07b46b98024c2ba2f9e83a10c2ef0515f057f2da299c1762a2017de80438b"
-dependencies = [
- "proc-macro2",
- "quote",
-]
-
 [[package]]
 name = "web-sys"
 version = "0.3.46"
diff --git a/Cargo.toml b/Cargo.toml
index 4b871996..0ed8fb00 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,14 +18,14 @@ rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "1f1f44f33
 #rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", default-features = false, features = ["tls"] }
 
 # Used for matrix spec type definitions and helpers
-ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks", "unstable-exhaustive-types"], rev = "ee814aa84934530d76f5e4b275d739805b49bdef" }
-# ruma = { git = "https://github.com/DevinR528/ruma", features = ["rand", "client-api", "federation-api", "unstable-exhaustive-types", "unstable-pre-spec", "unstable-synapse-quirks"], branch = "unstable-join" }
+ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks", "unstable-exhaustive-types"], rev = "45d01011554f9d07739e9a5edf5498d8ac16f273" }
+# ruma = { git = "https://github.com/DevinR528/ruma", features = ["rand", "client-api", "federation-api", "unstable-exhaustive-types", "unstable-pre-spec", "unstable-synapse-quirks"], branch = "verified-export" }
 # ruma = { path = "../ruma/ruma", features = ["unstable-exhaustive-types", "rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"] }
 
 # Used when doing state resolution
 # state-res = { git = "https://github.com/timokoesters/state-res", branch = "timo-spec-comp", features = ["unstable-pre-spec"] }
-state-res = { git = "https://github.com/ruma/state-res", branch = "timo-spec-comp", features = ["unstable-pre-spec", "gen-eventid"] }
-#state-res = { path = "../state-res", features = ["unstable-pre-spec", "gen-eventid"] }
+state-res = { git = "https://github.com/ruma/state-res", branch = "conflict", features = ["unstable-pre-spec", "gen-eventid"] }
+# state-res = { path = "../../state-res", features = ["unstable-pre-spec", "gen-eventid"] }
 
 # Used for long polling and federation sender, should be the same as rocket::tokio
 tokio = { version = "0.2.23" }
diff --git a/src/main.rs b/src/main.rs
index 9c0eab65..fe7ab0d2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -178,6 +178,6 @@ async fn main() {
 }
 
 #[catch(404)]
-fn not_found_catcher(_req: &'_ Request<'_>) -> String {
+fn not_found_catcher(_: &Request<'_>) -> String {
     "404 Not Found".to_owned()
 }
diff --git a/src/pdu.rs b/src/pdu.rs
index 75ef4927..f6ec4156 100644
--- a/src/pdu.rs
+++ b/src/pdu.rs
@@ -17,7 +17,7 @@ use std::{
     time::UNIX_EPOCH,
 };
 
-#[derive(Deserialize, Serialize, Debug)]
+#[derive(Clone, Deserialize, Serialize, Debug)]
 pub struct PduEvent {
     pub event_id: EventId,
     pub room_id: RoomId,
diff --git a/src/ruma_wrapper.rs b/src/ruma_wrapper.rs
index 0fdca743..ce0cc743 100644
--- a/src/ruma_wrapper.rs
+++ b/src/ruma_wrapper.rs
@@ -1,6 +1,6 @@
 use crate::Error;
 use ruma::{
-    api::{AuthScheme, OutgoingRequest},
+    api::{AuthScheme, IncomingRequest, OutgoingRequest},
     identifiers::{DeviceId, UserId},
     Outgoing,
 };
@@ -29,7 +29,7 @@ use {
 
 /// This struct converts rocket requests into ruma structs by converting them into http requests
 /// first.
-pub struct Ruma<T: Outgoing> {
+pub struct Ruma<T: Outgoing + OutgoingRequest> {
     pub body: T::Incoming,
     pub sender_user: Option<UserId>,
     pub sender_device: Option<Box<DeviceId>>,
@@ -40,10 +40,7 @@ pub struct Ruma<T: Outgoing> {
 #[cfg(feature = "conduit_bin")]
 impl<'a, T: Outgoing + OutgoingRequest> FromTransformedData<'a> for Ruma<T>
 where
-    <T as Outgoing>::Incoming: TryFrom<http::request::Request<std::vec::Vec<u8>>> + std::fmt::Debug,
-    <<T as Outgoing>::Incoming as std::convert::TryFrom<
-        http::request::Request<std::vec::Vec<u8>>,
-    >>::Error: std::fmt::Debug,
+    T::Incoming: IncomingRequest,
 {
     type Error = (); // TODO: Better error handling
     type Owned = Data;
@@ -149,8 +146,7 @@ where
 
             let http_request = http_request.body(body.clone()).unwrap();
             debug!("{:?}", http_request);
-
-            match <T as Outgoing>::Incoming::try_from(http_request) {
+            match <T::Incoming as IncomingRequest>::try_from_http_request(http_request) {
                 Ok(t) => Success(Ruma {
                     body: t,
                     sender_user,
@@ -170,7 +166,7 @@ where
     }
 }
 
-impl<T: Outgoing> Deref for Ruma<T> {
+impl<T: Outgoing + OutgoingRequest> Deref for Ruma<T> {
     type Target = T::Incoming;
 
     fn deref(&self) -> &Self::Target {
diff --git a/src/server_server.rs b/src/server_server.rs
index 7ff9e3f0..d68e9fae 100644
--- a/src/server_server.rs
+++ b/src/server_server.rs
@@ -1,7 +1,7 @@
 use crate::{client_server, utils, ConduitResult, Database, Error, PduEvent, Result, Ruma};
 use get_profile_information::v1::ProfileField;
 use http::header::{HeaderValue, AUTHORIZATION, HOST};
-use log::{info, warn};
+use log::{error, info, warn};
 use rocket::{get, post, put, response::content::Json, State};
 use ruma::{
     api::{
@@ -11,17 +11,18 @@ use ruma::{
                 get_server_keys, get_server_version::v1 as get_server_version, ServerSigningKeys,
                 VerifyKey,
             },
-            event::get_missing_events,
+            event::{get_missing_events, get_room_state, get_room_state_ids},
             query::get_profile_information,
             transactions::send_transaction_message,
         },
         OutgoingRequest,
     },
     directory::{IncomingFilter, IncomingRoomNetwork},
-    EventId, RoomId, ServerName, ServerSigningKeyId, UserId,
+    EventId, RoomId, RoomVersionId, ServerName, ServerSigningKeyId, UserId,
 };
+use state_res::StateMap;
 use std::{
-    collections::BTreeMap,
+    collections::{BTreeMap, BTreeSet},
     convert::TryFrom,
     fmt::Debug,
     net::{IpAddr, SocketAddr},
@@ -476,6 +477,34 @@ pub async fn get_public_rooms_route(
     .into())
 }
 
+#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
+pub enum PrevEvents<T> {
+    Sequential(T),
+    Fork(Vec<T>),
+}
+
+impl<T> IntoIterator for PrevEvents<T> {
+    type Item = T;
+    type IntoIter = std::vec::IntoIter<Self::Item>;
+
+    fn into_iter(self) -> Self::IntoIter {
+        match self {
+            Self::Sequential(item) => vec![item].into_iter(),
+            Self::Fork(list) => list.into_iter(),
+        }
+    }
+}
+
+impl<T: Clone> PrevEvents<T> {
+    pub fn new(id: &[T]) -> Self {
+        match id {
+            [] => panic!("All events must have previous event"),
+            [single_id] => Self::Sequential(single_id.clone()),
+            rest => Self::Fork(rest.to_vec()),
+        }
+    }
+}
+
 #[cfg_attr(
     feature = "conduit_bin",
     put("/_matrix/federation/v1/send/<_>", data = "<body>")
@@ -532,53 +561,313 @@ pub async fn send_transaction_message_route<'a>(
     // would return a M_BAD_JSON error.
     let mut resolved_map = BTreeMap::new();
     for pdu in &body.pdus {
-        // Ruma/PduEvent/StateEvent satisfies - 1. Is a valid event, otherwise it is dropped.
+        // 1. Is a valid event, otherwise it is dropped.
+        // Ruma/PduEvent/StateEvent satisfies this
 
-        // state-res checks signatures - 2. Passes signature checks, otherwise event is dropped.
-
-        // 3. Passes hash checks, otherwise it is redacted before being processed further.
-        // TODO: redact event if hashing fails
         let (event_id, value) = crate::pdu::process_incoming_pdu(pdu);
 
+        // 2. Passes signature checks, otherwise event is dropped.
+        // 3. Passes hash checks, otherwise it is redacted before being processed further.
+        let keys = db.globals.keypair();
+        let mut pub_key_set = BTreeMap::new();
+        pub_key_set.insert(
+            "ed25519:1".to_string(),
+            String::from_utf8(keys.public_key().to_vec()).expect("public key is valid utf8"),
+        );
+        let mut pub_key_map = BTreeMap::new();
+        pub_key_map.insert("domain".to_string(), pub_key_set);
+
+        let value =
+            match ruma::signatures::verify_event(&pub_key_map, &value, &RoomVersionId::Version6) {
+                Ok(ver) => {
+                    if let ruma::signatures::Verified::Signatures = ver {
+                        match ruma::signatures::redact(&value, &RoomVersionId::Version6) {
+                            Ok(obj) => obj,
+                            Err(_) => {
+                                resolved_map
+                                    .insert(event_id, Err("Room is unknown to this server".into()));
+                                continue;
+                            }
+                        }
+                    } else {
+                        value
+                    }
+                }
+                Err(_e) => {
+                    resolved_map.insert(event_id, Err("Room is unknown to this server".into()));
+                    continue;
+                }
+            };
+
         let pdu = serde_json::from_value::<PduEvent>(
             serde_json::to_value(&value).expect("CanonicalJsonObj is a valid JsonValue"),
         )
         .expect("all ruma pdus are conduit pdus");
-        let room_id = &pdu.room_id;
 
         // If we have no idea about this room skip the PDU
-        if !db.rooms.exists(room_id)? {
+        if !db.rooms.exists(&pdu.room_id)? {
             resolved_map.insert(event_id, Err("Room is unknown to this server".into()));
             continue;
         }
 
-        let count = db.globals.next_count()?;
-        let mut pdu_id = room_id.as_bytes().to_vec();
-        pdu_id.push(0xff);
-        pdu_id.extend_from_slice(&count.to_be_bytes());
+        // TODO: remove the need to convert to state_res
+        let event = pdu.convert_for_state_res();
+        let previous = pdu
+            .prev_events
+            .first()
+            .map(|id| {
+                db.rooms
+                    .get_pdu(id)
+                    .expect("todo")
+                    .map(|ev| ev.convert_for_state_res())
+            })
+            .flatten();
 
-        db.rooms.append_to_state(&pdu_id, &pdu, &db.globals)?;
-
-        db.rooms.append_pdu(
-            &pdu,
-            value,
-            count,
-            pdu_id.clone().into(),
-            &db.globals,
-            &db.account_data,
-            &db.admin,
+        // 4.
+        let auth_events = db.rooms.get_auth_events(
+            &pdu.room_id,
+            &pdu.kind,
+            &pdu.sender,
+            pdu.state_key.as_deref(),
+            pdu.content.clone(),
         )?;
-
-        for appservice in db.appservice.iter_all().filter_map(|r| r.ok()) {
-            db.sending.send_pdu_appservice(&appservice.0, &pdu_id)?;
+        if !state_res::event_auth::auth_check(
+            &RoomVersionId::Version6,
+            &event,
+            previous.clone(),
+            auth_events
+                .into_iter()
+                .map(|(k, v)| (k, v.convert_for_state_res()))
+                .collect(),
+            None,
+        )
+        .map_err(|_e| Error::Conflict("Auth check failed"))?
+        {
+            resolved_map.insert(
+                event.event_id(),
+                Err("Event has failed auth check with auth events".into()),
+            );
+            continue;
         }
 
-        resolved_map.insert(event_id, Ok::<(), String>(()));
+        let mut previous_states = vec![];
+        for id in &pdu.prev_events {
+            if let Some(id) = db.rooms.get_pdu_id(id)? {
+                let state_hash = db
+                    .rooms
+                    .pdu_state_hash(&id)?
+                    .expect("found pdu with no statehash");
+                let state = db.rooms.state_full(&pdu.room_id, &state_hash)?;
+                previous_states.push(state);
+            } else {
+                // fetch the state
+                match db
+                    .sending
+                    .send_federation_request(
+                        &db.globals,
+                        body.body.origin,
+                        get_room_state_ids::v1::Request {
+                            room_id: &pdu.room_id,
+                            event_id: id,
+                        },
+                    )
+                    .await
+                {
+                    Ok(res) => todo!(),
+                    Err(e) => panic!(e),
+                }
+            }
+        }
+
+        // 5. Passes authorization rules based on the state at the event, otherwise it is rejected.
+        let state_at_event = if previous_states.is_empty() {
+            // State is empty
+            Default::default()
+        } else if previous_states.len() == 1 {
+            previous_states[0].clone()
+        } else {
+            match state_res::StateResolution::resolve(
+                &pdu.room_id,
+                &RoomVersionId::Version6,
+                &previous_states
+                    .into_iter()
+                    .map(|map| {
+                        map.into_iter()
+                            .map(|(k, v)| (k, v.event_id))
+                            .collect::<StateMap<_>>()
+                    })
+                    .collect::<Vec<_>>(),
+                None,
+                &db.rooms,
+            ) {
+                Ok(res) => res
+                    .into_iter()
+                    .map(|(k, v)| (k, db.rooms.get_pdu(&v).unwrap().unwrap()))
+                    .collect(),
+                Err(e) => panic!("{:?}", e),
+            }
+        };
+
+        if !state_res::event_auth::auth_check(
+            &RoomVersionId::Version6,
+            &event,
+            previous.clone(),
+            state_at_event
+                .into_iter()
+                .map(|(k, v)| (k, v.convert_for_state_res()))
+                .collect(),
+            None,
+        )
+        .map_err(|_e| Error::Conflict("Auth check failed"))?
+        {
+            // Event failed auth with state_at
+            resolved_map.insert(
+                event.event_id(),
+                Err("Event has failed auth check with state at the event".into()),
+            );
+            continue;
+        }
+
+        // The event could still be soft failed
+        append_state_soft(&db, &pdu)?;
+
+        // Gather the forward extremities and resolve
+        let forward_extrems = forward_extremity_ids(&db, &pdu.room_id)?;
+        let mut fork_states = vec![];
+        for id in &forward_extrems {
+            if let Some(id) = db.rooms.get_pdu_id(id)? {
+                let state_hash = db
+                    .rooms
+                    .pdu_state_hash(&id)?
+                    .expect("found pdu with no statehash");
+                let state = db.rooms.state_full(&pdu.room_id, &state_hash)?;
+                fork_states.push(state);
+            } else {
+                // This is probably an error??
+                match db
+                    .sending
+                    .send_federation_request(
+                        &db.globals,
+                        body.body.origin,
+                        get_room_state_ids::v1::Request {
+                            room_id: &pdu.room_id,
+                            event_id: id,
+                        },
+                    )
+                    .await
+                {
+                    Ok(res) => todo!(),
+                    Err(e) => panic!(e),
+                }
+            }
+        }
+
+        // 6.
+        let state_at_forks = if fork_states.is_empty() {
+            // State is empty
+            Default::default()
+        } else if fork_states.len() == 1 {
+            fork_states[0].clone()
+        } else {
+            match state_res::StateResolution::resolve(
+                &pdu.room_id,
+                &RoomVersionId::Version6,
+                &fork_states
+                    .into_iter()
+                    .map(|map| {
+                        map.into_iter()
+                            .map(|(k, v)| (k, v.event_id))
+                            .collect::<StateMap<_>>()
+                    })
+                    .collect::<Vec<_>>(),
+                None,
+                &db.rooms,
+            ) {
+                Ok(res) => res
+                    .into_iter()
+                    .map(|(k, v)| (k, db.rooms.get_pdu(&v).unwrap().unwrap()))
+                    .collect(),
+                Err(e) => panic!("{:?}", e),
+            }
+        };
+
+        if !state_res::event_auth::auth_check(
+            &RoomVersionId::Version6,
+            &event,
+            previous,
+            state_at_forks
+                .into_iter()
+                .map(|(k, v)| (k, v.convert_for_state_res()))
+                .collect(),
+            None,
+        )
+        .map_err(|_e| Error::Conflict("Auth check failed"))?
+        {
+            // Soft fail
+            resolved_map.insert(event.event_id(), Err("Event has been soft failed".into()));
+        } else {
+            append_state(&db, &pdu)?;
+            // Event has passed all auth/stateres checks
+            resolved_map.insert(event.event_id(), Ok(()));
+        }
     }
 
     Ok(send_transaction_message::v1::Response { pdus: resolved_map }.into())
 }
 
+fn forward_extremity_ids(db: &Database, room_id: &RoomId) -> Result<Vec<EventId>> {
+    todo!()
+}
+
+fn append_state(db: &Database, pdu: &PduEvent) -> Result<()> {
+    let count = db.globals.next_count()?;
+    let mut pdu_id = pdu.room_id.as_bytes().to_vec();
+    pdu_id.push(0xff);
+    pdu_id.extend_from_slice(&count.to_be_bytes());
+
+    db.rooms.append_to_state(&pdu_id, pdu, &db.globals)?;
+    db.rooms.append_pdu(
+        pdu,
+        &utils::to_canonical_object(pdu).expect("Pdu is valid canonical object"),
+        count,
+        pdu_id.clone().into(),
+        &db.globals,
+        &db.account_data,
+        &db.admin,
+    )?;
+
+    for appservice in db.appservice.iter_all().filter_map(|r| r.ok()) {
+        db.sending.send_pdu_appservice(&appservice.0, &pdu_id)?;
+    }
+
+    Ok(())
+}
+
+/// TODO: This should not write to the current room state (roomid_statehash)
+fn append_state_soft(db: &Database, pdu: &PduEvent) -> Result<()> {
+    let count = db.globals.next_count()?;
+    let mut pdu_id = pdu.room_id.as_bytes().to_vec();
+    pdu_id.push(0xff);
+    pdu_id.extend_from_slice(&count.to_be_bytes());
+
+    db.rooms.append_to_state(&pdu_id, pdu, &db.globals)?;
+    db.rooms.append_pdu(
+        pdu,
+        &utils::to_canonical_object(pdu).expect("Pdu is valid canonical object"),
+        count,
+        pdu_id.clone().into(),
+        &db.globals,
+        &db.account_data,
+        &db.admin,
+    )?;
+
+    for appservice in db.appservice.iter_all().filter_map(|r| r.ok()) {
+        db.sending.send_pdu_appservice(&appservice.0, &pdu_id)?;
+    }
+
+    Ok(())
+}
+
 #[cfg_attr(
     feature = "conduit_bin",
     post("/_matrix/federation/v1/get_missing_events/<_>", data = "<body>")