diff --git a/buildSrc/src/main/kotlin/de/kuschku/justcode/NullOutputStream.kt b/buildSrc/src/main/kotlin/de/kuschku/justcode/NullOutputStream.kt
new file mode 100644
index 0000000000000000000000000000000000000000..305b88c3bbaad175a75e4eb79e83c3d96990fac7
--- /dev/null
+++ b/buildSrc/src/main/kotlin/de/kuschku/justcode/NullOutputStream.kt
@@ -0,0 +1,51 @@
+/*
+ * Quasseldroid - Quassel client for Android
+ *
+ * Copyright (c) 2021 Janne Mareike Koschinski
+ * Copyright (c) 2021 The Quassel Project
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.kuschku.justcode
+
+import java.io.IOException
+import java.io.OutputStream
+import java.util.*
+
+class NullOutputStream : OutputStream() {
+  @Volatile
+  private var closed = false
+
+  @Throws(IOException::class)
+  private fun ensureOpen() {
+    if (closed) {
+      throw IOException("Stream closed")
+    }
+  }
+
+  @Throws(IOException::class)
+  override fun write(b: Int) {
+    ensureOpen()
+  }
+
+  @Throws(IOException::class)
+  override fun write(b: ByteArray, off: Int, len: Int) {
+      Objects.checkFromIndexSize(off, len, b.size)
+    ensureOpen()
+  }
+
+  override fun close() {
+    closed = true
+  }
+}
diff --git a/buildSrc/src/main/kotlin/de/kuschku/justcode/ProjectHelper.kt b/buildSrc/src/main/kotlin/de/kuschku/justcode/ProjectHelper.kt
index c000a6ce9f3b6185a95918a6fa6f38bbb45e58e2..bcde26ff39e2dcf0209fc9df46cb6859f155d1ca 100644
--- a/buildSrc/src/main/kotlin/de/kuschku/justcode/ProjectHelper.kt
+++ b/buildSrc/src/main/kotlin/de/kuschku/justcode/ProjectHelper.kt
@@ -21,7 +21,6 @@ package de.kuschku.justcode
 
 import org.gradle.api.Project
 import java.io.ByteArrayOutputStream
-import java.io.OutputStream
 import java.util.*
 
 fun Project.cmd(vararg command: String) = try {
@@ -29,7 +28,7 @@ fun Project.cmd(vararg command: String) = try {
   exec {
     commandLine(*command)
     standardOutput = stdOut
-    errorOutput = OutputStream.nullOutputStream()
+    errorOutput = NullOutputStream()
   }
   stdOut.toString(Charsets.UTF_8.name()).trim()
 } catch (e: Throwable) {
@@ -51,7 +50,7 @@ inline fun <reified T> setBuildConfigField(
   value: T
 ) {
   if (T::class == Long::class) {
-    setter("long", name, "${value?:0}L")
+    setter("long", name, "${value ?: 0}L")
   } else if (T::class == String::class) {
     setter("String", name, "\"${value}\"")
   }
diff --git a/protocol/src/main/java/de/kuschku/libquassel/protocol/types/BufferId.kt b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/BufferId.kt
new file mode 100644
index 0000000000000000000000000000000000000000..5664ee365ba227709fd4cc9039d8454f8ff08ae0
--- /dev/null
+++ b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/BufferId.kt
@@ -0,0 +1,31 @@
+/*
+ * Quasseldroid - Quassel client for Android
+ *
+ * Copyright (c) 2021 Janne Mareike Koschinski
+ * Copyright (c) 2021 The Quassel Project
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.kuschku.libquassel.protocol.types
+
+private typealias BufferIdType = SignedIdType
+
+inline class BufferId(override val id: BufferIdType) : SignedId<BufferIdType> {
+  override fun toString() = "BufferId($id)"
+
+  companion object {
+    val MIN_VALUE = BufferId(BufferIdType.MIN_VALUE)
+    val MAX_VALUE = BufferId(BufferIdType.MAX_VALUE)
+  }
+}
diff --git a/protocol/src/main/java/de/kuschku/libquassel/protocol/types/IdentityId.kt b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/IdentityId.kt
new file mode 100644
index 0000000000000000000000000000000000000000..bd2c4ba04084dcab93caa39fdc6b1fe047a5115d
--- /dev/null
+++ b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/IdentityId.kt
@@ -0,0 +1,31 @@
+/*
+ * Quasseldroid - Quassel client for Android
+ *
+ * Copyright (c) 2021 Janne Mareike Koschinski
+ * Copyright (c) 2021 The Quassel Project
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.kuschku.libquassel.protocol.types
+
+private typealias IdentityIdType = SignedIdType
+
+inline class IdentityId(override val id: IdentityIdType) : SignedId<IdentityIdType> {
+  override fun toString() = "IdentityId($id)"
+
+  companion object {
+    val MIN_VALUE = IdentityId(IdentityIdType.MIN_VALUE)
+    val MAX_VALUE = IdentityId(IdentityIdType.MAX_VALUE)
+  }
+}
diff --git a/protocol/src/main/java/de/kuschku/libquassel/protocol/types/MsgId.kt b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/MsgId.kt
new file mode 100644
index 0000000000000000000000000000000000000000..c06ee0e3e7a935625eed2076753c2f4f9798a0e8
--- /dev/null
+++ b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/MsgId.kt
@@ -0,0 +1,31 @@
+/*
+ * Quasseldroid - Quassel client for Android
+ *
+ * Copyright (c) 2021 Janne Mareike Koschinski
+ * Copyright (c) 2021 The Quassel Project
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.kuschku.libquassel.protocol.types
+
+private typealias MsgIdType = SignedId64Type
+
+inline class MsgId(override val id: MsgIdType) : SignedId<MsgIdType> {
+  override fun toString() = "MsgId($id)"
+
+  companion object {
+    val MIN_VALUE = MsgId(MsgIdType.MIN_VALUE)
+    val MAX_VALUE = MsgId(MsgIdType.MAX_VALUE)
+  }
+}
diff --git a/protocol/src/main/java/de/kuschku/libquassel/protocol/types/NetworkId.kt b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/NetworkId.kt
new file mode 100644
index 0000000000000000000000000000000000000000..81ee3c8a52afdb048fad0b5605594c79fe453925
--- /dev/null
+++ b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/NetworkId.kt
@@ -0,0 +1,31 @@
+/*
+ * Quasseldroid - Quassel client for Android
+ *
+ * Copyright (c) 2021 Janne Mareike Koschinski
+ * Copyright (c) 2021 The Quassel Project
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.kuschku.libquassel.protocol.types
+
+private typealias NetworkIdType = SignedIdType
+
+inline class NetworkId(override val id: NetworkIdType) : SignedId<NetworkIdType> {
+  override fun toString() = "NetworkId($id)"
+
+  companion object {
+    val MIN_VALUE = NetworkId(NetworkIdType.MIN_VALUE)
+    val MAX_VALUE = NetworkId(NetworkIdType.MAX_VALUE)
+  }
+}
diff --git a/protocol/src/main/java/de/kuschku/libquassel/protocol/types/SignedId.kt b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/SignedId.kt
new file mode 100644
index 0000000000000000000000000000000000000000..b1e1efdee979712462262fe13a6b1da2a4783cc9
--- /dev/null
+++ b/protocol/src/main/java/de/kuschku/libquassel/protocol/types/SignedId.kt
@@ -0,0 +1,46 @@
+/*
+ * Quasseldroid - Quassel client for Android
+ *
+ * Copyright (c) 2021 Janne Mareike Koschinski
+ * Copyright (c) 2021 The Quassel Project
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.kuschku.libquassel.protocol.types
+
+import java.io.Serializable
+
+typealias SignedIdType = Int
+typealias SignedId64Type = Long
+
+interface SignedId<T> : Serializable, Comparable<SignedId<T>>
+  where T : Number, T : Comparable<T> {
+  val id: T
+
+  override fun compareTo(other: SignedId<T>): Int {
+    return id.compareTo(other.id)
+  }
+}
+
+@Suppress("NOTHING_TO_INLINE")
+@JvmName("isValidId")
+inline fun SignedId<SignedIdType>.isValid() = id > 0
+
+@Suppress("NOTHING_TO_INLINE")
+@JvmName("isValidId64")
+inline fun SignedId<SignedId64Type>.isValid() = id > 0
+
+
+
+