diff --git a/bbootimg/src/main/kotlin/Helper.kt b/bbootimg/src/main/kotlin/Helper.kt
index b0d2d01..d445adc 100644
--- a/bbootimg/src/main/kotlin/Helper.kt
+++ b/bbootimg/src/main/kotlin/Helper.kt
@@ -23,6 +23,7 @@ import java.util.zip.GZIPOutputStream
 import javax.crypto.Cipher
 
 class Helper {
+    @ExperimentalUnsignedTypes
     companion object {
         fun joinWithNulls(vararg source: ByteArray?): ByteArray {
             val baos = ByteArrayOutputStream()
@@ -131,6 +132,7 @@ class Helper {
             This MAY not be a problem, at least we didn't find it till now.
          */
         @Throws(IOException::class)
+        @Deprecated("this function misses features")
         fun gnuZipFile(compressedFile: String, fis: InputStream) {
             val buffer = ByteArray(1024)
             FileOutputStream(compressedFile).use { fos ->
diff --git a/bbootimg/src/main/kotlin/KeyUtil.kt b/bbootimg/src/main/kotlin/KeyUtil.kt
index 030169e..ead062a 100644
--- a/bbootimg/src/main/kotlin/KeyUtil.kt
+++ b/bbootimg/src/main/kotlin/KeyUtil.kt
@@ -24,7 +24,7 @@ class KeyUtil {
         }
 
         fun parsePemPrivateKey2(inputStream: InputStream): PrivateKey {
-            val rsa = KeyUtil.parsePemPrivateKey(inputStream)
+            val rsa = parsePemPrivateKey(inputStream)
             return generateRsaPrivateKey(rsa.modulus, rsa.privateExponent)
         }
 
diff --git a/bbootimg/src/main/kotlin/ParamConfig.kt b/bbootimg/src/main/kotlin/ParamConfig.kt
index d6a9fc8..7a23d2e 100644
--- a/bbootimg/src/main/kotlin/ParamConfig.kt
+++ b/bbootimg/src/main/kotlin/ParamConfig.kt
@@ -1,5 +1,6 @@
 package cfig
 
+@ExperimentalUnsignedTypes
 data class ParamConfig(
         //file input
         var kernel: String = UnifiedConfig.workDir + "kernel",
diff --git a/bbootimg/src/main/kotlin/R.kt b/bbootimg/src/main/kotlin/R.kt
index a696baa..aeeb0b7 100755
--- a/bbootimg/src/main/kotlin/R.kt
+++ b/bbootimg/src/main/kotlin/R.kt
@@ -4,7 +4,9 @@ import cfig.bootimg.BootImgInfo
 import de.vandermeer.asciitable.AsciiTable
 import org.slf4j.LoggerFactory
 import java.io.File
+import kotlin.system.exitProcess
 
+@ExperimentalUnsignedTypes
 fun main(args: Array<String>) {
     val log = LoggerFactory.getLogger("Launcher")
     if ((args.size == 6) && args[0] in setOf("pack", "unpack", "sign")) {
@@ -84,7 +86,7 @@ fun main(args: Array<String>) {
         println("Usage: unpack <boot_image_path> <mkbootimg_bin_path> <avbtool_path> <boot_signer_path> <mkbootfs_bin_path>")
         println("Usage:  pack  <boot_image_path> <mkbootimg_bin_path> <avbtool_path> <boot_signer_path> <mkbootfs_bin_path>")
         println("Usage:  sign  <boot_image_path> <mkbootimg_bin_path> <avbtool_path> <boot_signer_path> <mkbootfs_bin_path>")
-        System.exit(1)
+        exitProcess(1)
     }
 }
 
diff --git a/bbootimg/src/main/kotlin/Signer.kt b/bbootimg/src/main/kotlin/Signer.kt
index 3ac143f..7aff834 100644
--- a/bbootimg/src/main/kotlin/Signer.kt
+++ b/bbootimg/src/main/kotlin/Signer.kt
@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory
 import java.io.File
 
 class Signer {
+    @ExperimentalUnsignedTypes
     companion object {
         private val log = LoggerFactory.getLogger(Signer::class.java)
 
@@ -38,9 +39,9 @@ class Signer {
                     //our signer
                     File(cfg.info.output + ".clear").copyTo(File(cfg.info.output + ".signed"))
                     Avb().add_hash_footer(cfg.info.output + ".signed",
-                            info2.imageSize.toLong(),
-                            false,
-                            false,
+                            info2.imageSize,
+                            use_persistent_digest = false,
+                            do_not_use_ab = false,
                             salt = Helper.toHexString(bootDesc.salt),
                             hash_algorithm = bootDesc.hash_algorithm_str,
                             partition_name = bootDesc.partition_name,
diff --git a/bbootimg/src/main/kotlin/UnifiedConfig.kt b/bbootimg/src/main/kotlin/UnifiedConfig.kt
index b7bdcb2..effd7d7 100644
--- a/bbootimg/src/main/kotlin/UnifiedConfig.kt
+++ b/bbootimg/src/main/kotlin/UnifiedConfig.kt
@@ -3,9 +3,9 @@ package cfig
 import cfig.bootimg.BootImgInfo
 import com.fasterxml.jackson.annotation.JsonInclude
 import com.fasterxml.jackson.databind.ObjectMapper
-import org.slf4j.LoggerFactory
 import java.io.File
 
+@ExperimentalUnsignedTypes
 @JsonInclude(JsonInclude.Include.NON_NULL)
 data class UnifiedConfig(
         var info: MiscInfo = MiscInfo(),
@@ -22,6 +22,7 @@ data class UnifiedConfig(
             var size: String = "0",
             var loadOffset: String = "0")
 
+    @ExperimentalUnsignedTypes
     data class MiscInfo(
             var output: String = "",
             var headerVersion: UInt = 0U,
@@ -82,7 +83,6 @@ data class UnifiedConfig(
 
     companion object {
         const val workDir = "build/unzip_boot/"
-        private val log = LoggerFactory.getLogger(UnifiedConfig::class.java)
 
         fun fromBootImgInfo(info: BootImgInfo): UnifiedConfig {
             val ret = UnifiedConfig()
@@ -123,7 +123,7 @@ data class UnifiedConfig(
                 if (info.dtbLength > 0U) {
                     ret.dtb!!.file = param.dtb
                 }
-                ret.dtb!!.loadOffset = "0x${java.lang.Integer.toHexString(info.dtbOffset.toInt())}"
+                ret.dtb!!.loadOffset = "0x${Integer.toHexString(info.dtbOffset.toInt())}"
                 ret.dtb!!.size = "0x${Integer.toHexString(info.dtbLength.toInt())}"
                 ret.dtb!!.position = "0x${java.lang.Long.toHexString(info.dtbPosition.toLong())}"
             }
diff --git a/bbootimg/src/main/kotlin/avb/AVBInfo.kt b/bbootimg/src/main/kotlin/avb/AVBInfo.kt
index 9d2290a..4dbee39 100755
--- a/bbootimg/src/main/kotlin/avb/AVBInfo.kt
+++ b/bbootimg/src/main/kotlin/avb/AVBInfo.kt
@@ -3,6 +3,7 @@ package avb
 /*
     a wonderfaul base64 encoder/decoder: https://cryptii.com/base64-to-hex
  */
+@ExperimentalUnsignedTypes
 class AVBInfo(var header: Header? = null,
               var authBlob: AuthBlob? = null,
               var auxBlob: AuxBlob? = null,
diff --git a/bbootimg/src/main/kotlin/avb/AuthBlob.kt b/bbootimg/src/main/kotlin/avb/AuthBlob.kt
index 93329f7..6d21421 100644
--- a/bbootimg/src/main/kotlin/avb/AuthBlob.kt
+++ b/bbootimg/src/main/kotlin/avb/AuthBlob.kt
@@ -1,5 +1,6 @@
 package avb
 
+@ExperimentalUnsignedTypes
 data class AuthBlob(
         var offset: ULong = 0U,
         var size: ULong = 0U,
diff --git a/bbootimg/src/main/kotlin/avb/AuxBlob.kt b/bbootimg/src/main/kotlin/avb/AuxBlob.kt
index bd1cc59..ec86e20 100644
--- a/bbootimg/src/main/kotlin/avb/AuxBlob.kt
+++ b/bbootimg/src/main/kotlin/avb/AuxBlob.kt
@@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory
 import java.nio.file.Files
 import java.nio.file.Paths
 
+@ExperimentalUnsignedTypes
 data class AuxBlob(
         var pubkey: PubKeyInfo? = null,
         var pubkeyMeta: PubKeyMetadataInfo? = null,
diff --git a/bbootimg/src/main/kotlin/avb/Avb.kt b/bbootimg/src/main/kotlin/avb/Avb.kt
index 74ebbdc..03f834d 100755
--- a/bbootimg/src/main/kotlin/avb/Avb.kt
+++ b/bbootimg/src/main/kotlin/avb/Avb.kt
@@ -16,6 +16,7 @@ import java.nio.file.Paths
 import java.nio.file.StandardOpenOption
 import java.security.MessageDigest
 
+@ExperimentalUnsignedTypes
 class Avb {
     private val MAX_VBMETA_SIZE = 64 * 1024
     private val MAX_FOOTER_SIZE = 4096
@@ -173,7 +174,7 @@ class Avb {
     }
 
     //avbtool::Avb::_generate_vbmeta_blob()
-    fun generateVbMetaBlob(algorithm_name: String,
+    private fun generateVbMetaBlob(algorithm_name: String,
                            public_key_metadata_path: String?,
                            descriptors: Array<Descriptor>,
                            chain_partitions: String?,
@@ -373,7 +374,7 @@ class Avb {
         return ai
     }
 
-    fun packVbMeta(info: AVBInfo? = null): ByteArray {
+    private fun packVbMeta(info: AVBInfo? = null): ByteArray {
         val ai = info ?: ObjectMapper().readValue(File(getJsonFileName("vbmeta.img")), AVBInfo::class.java)
         val alg = Algorithms.get(ai.header!!.algorithm_type.toInt())!!
         val encodedDesc = ai.auxBlob!!.encodeDescriptors()
diff --git a/bbootimg/src/main/kotlin/avb/Blob.kt b/bbootimg/src/main/kotlin/avb/Blob.kt
index de951cb..327b0de 100644
--- a/bbootimg/src/main/kotlin/avb/Blob.kt
+++ b/bbootimg/src/main/kotlin/avb/Blob.kt
@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory
 import java.security.MessageDigest
 
 class Blob {
+    @ExperimentalUnsignedTypes
     companion object {
         private val log = LoggerFactory.getLogger(Blob::class.java)
 
diff --git a/bbootimg/src/main/kotlin/avb/Footer.kt b/bbootimg/src/main/kotlin/avb/Footer.kt
index 43f6b13..12329b2 100644
--- a/bbootimg/src/main/kotlin/avb/Footer.kt
+++ b/bbootimg/src/main/kotlin/avb/Footer.kt
@@ -24,6 +24,7 @@ https://github.com/cfig/Android_boot_image_editor/blob/master/doc/layout.md#32-a
 +---------------------------------------+-------------------------+ --> partition_size
  */
 
+@ExperimentalUnsignedTypes
 data class Footer constructor(
         var versionMajor: UInt = FOOTER_VERSION_MAJOR,
         var versionMinor: UInt = FOOTER_VERSION_MINOR,
diff --git a/bbootimg/src/main/kotlin/avb/Header.kt b/bbootimg/src/main/kotlin/avb/Header.kt
index 3ecc56f..7e3ce7b 100644
--- a/bbootimg/src/main/kotlin/avb/Header.kt
+++ b/bbootimg/src/main/kotlin/avb/Header.kt
@@ -1,12 +1,12 @@
 package avb
 
 import cfig.Avb
-import cfig.Helper
 import cfig.io.Struct3
 import org.junit.Assert
 import java.io.InputStream
 
 //avbtool::AvbVBMetaHeader
+@ExperimentalUnsignedTypes
 data class Header(
         var required_libavb_version_major: UInt = Avb.AVB_VERSION_MAJOR,
         var required_libavb_version_minor: UInt = 0U,
diff --git a/bbootimg/src/main/kotlin/avb/VBMeta.kt b/bbootimg/src/main/kotlin/avb/VBMeta.kt
index 5d05175..7584339 100644
--- a/bbootimg/src/main/kotlin/avb/VBMeta.kt
+++ b/bbootimg/src/main/kotlin/avb/VBMeta.kt
@@ -1,5 +1,6 @@
 package avb
 
+@ExperimentalUnsignedTypes
 class VBMeta(var header: Header? = null,
              var authBlob: AuthBlob? = null,
              var auxBlob: AuxBlob? = null) {
diff --git a/bbootimg/src/main/kotlin/avb/alg/Algorithms.kt b/bbootimg/src/main/kotlin/avb/alg/Algorithms.kt
index 5c77c3e..4248a57 100644
--- a/bbootimg/src/main/kotlin/avb/alg/Algorithms.kt
+++ b/bbootimg/src/main/kotlin/avb/alg/Algorithms.kt
@@ -3,6 +3,7 @@ package avb.alg
 import cfig.io.Struct3
 
 class Algorithms {
+    @ExperimentalUnsignedTypes
     companion object {
         private val algMap = mutableMapOf<String, Algorithm>()
         fun get(name: String): Algorithm? {
diff --git a/bbootimg/src/main/kotlin/avb/desc/ChainPartitionDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/ChainPartitionDescriptor.kt
index 60daabd..c807c50 100644
--- a/bbootimg/src/main/kotlin/avb/desc/ChainPartitionDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/ChainPartitionDescriptor.kt
@@ -6,6 +6,7 @@ import java.io.InputStream
 import java.security.MessageDigest
 import java.util.*
 
+@ExperimentalUnsignedTypes
 class ChainPartitionDescriptor(
         var rollback_index_location: UInt = 0U,
         var partition_name_len: UInt = 0U,
diff --git a/bbootimg/src/main/kotlin/avb/desc/Descriptor.kt b/bbootimg/src/main/kotlin/avb/desc/Descriptor.kt
index 1b06462..39924fe 100755
--- a/bbootimg/src/main/kotlin/avb/desc/Descriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/Descriptor.kt
@@ -1,5 +1,6 @@
 package avb.desc
 
+@ExperimentalUnsignedTypes
 abstract class Descriptor(var tag: ULong, var num_bytes_following: ULong, var sequence: Int = 0) {
     abstract fun encode(): ByteArray
 }
\ No newline at end of file
diff --git a/bbootimg/src/main/kotlin/avb/desc/HashDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/HashDescriptor.kt
index b97d38e..c5188ca 100755
--- a/bbootimg/src/main/kotlin/avb/desc/HashDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/HashDescriptor.kt
@@ -7,6 +7,7 @@ import java.io.File
 import java.io.InputStream
 import java.security.MessageDigest
 
+@ExperimentalUnsignedTypes
 class HashDescriptor(var image_size: ULong = 0U,
                      var hash_algorithm: String = "",
                      var hash_algorithm_str: String = "",
@@ -60,7 +61,7 @@ class HashDescriptor(var image_size: ULong = 0U,
     }
 
     fun verify(image_file: String) {
-        val hasher = MessageDigest.getInstance(Helper.pyAlg2java(hash_algorithm.toString()))
+        val hasher = MessageDigest.getInstance(Helper.pyAlg2java(hash_algorithm))
         hasher.update(this.salt)
         hasher.update(File(image_file).readBytes())
         val digest = hasher.digest()
diff --git a/bbootimg/src/main/kotlin/avb/desc/HashTreeDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/HashTreeDescriptor.kt
index 121e69a..0857a2b 100755
--- a/bbootimg/src/main/kotlin/avb/desc/HashTreeDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/HashTreeDescriptor.kt
@@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory
 import java.io.InputStream
 import java.util.*
 
+@ExperimentalUnsignedTypes
 class HashTreeDescriptor(
         var dm_verity_version: UInt = 0u,
         var image_size: ULong = 0UL,
@@ -86,6 +87,5 @@ class HashTreeDescriptor(
         private const val RESERVED = 60L
         private const val SIZE = 120 + RESERVED
         private const val FORMAT_STRING = "!2QL3Q3L2Q32s4L${RESERVED}x"
-        private val log = LoggerFactory.getLogger(HashTreeDescriptor::class.java)
     }
 }
\ No newline at end of file
diff --git a/bbootimg/src/main/kotlin/avb/desc/KernelCmdlineDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/KernelCmdlineDescriptor.kt
index a33c51f..693f414 100755
--- a/bbootimg/src/main/kotlin/avb/desc/KernelCmdlineDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/KernelCmdlineDescriptor.kt
@@ -5,6 +5,7 @@ import cfig.io.Struct3
 import org.junit.Assert
 import java.io.InputStream
 
+@ExperimentalUnsignedTypes
 class KernelCmdlineDescriptor(
         var flags: UInt = 0U,
         var cmdlineLength: UInt = 0U,
diff --git a/bbootimg/src/main/kotlin/avb/desc/PropertyDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/PropertyDescriptor.kt
index 9436270..ec50111 100755
--- a/bbootimg/src/main/kotlin/avb/desc/PropertyDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/PropertyDescriptor.kt
@@ -4,6 +4,7 @@ import cfig.Helper
 import cfig.io.Struct3
 import java.io.InputStream
 
+@ExperimentalUnsignedTypes
 class PropertyDescriptor(
         var key: String = "",
         var value: String = "") : Descriptor(TAG, 0U, 0) {
diff --git a/bbootimg/src/main/kotlin/avb/desc/UnknownDescriptor.kt b/bbootimg/src/main/kotlin/avb/desc/UnknownDescriptor.kt
index 7af0f58..98eb144 100755
--- a/bbootimg/src/main/kotlin/avb/desc/UnknownDescriptor.kt
+++ b/bbootimg/src/main/kotlin/avb/desc/UnknownDescriptor.kt
@@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory
 import java.io.ByteArrayInputStream
 import java.io.InputStream
 
+@ExperimentalUnsignedTypes
 class UnknownDescriptor(var data: ByteArray = byteArrayOf()) : Descriptor(0U, 0U, 0) {
     @Throws(IllegalArgumentException::class)
     constructor(stream: InputStream, seq: Int = 0) : this() {
diff --git a/bbootimg/src/main/kotlin/bootimg/BootImgHeader.kt b/bbootimg/src/main/kotlin/bootimg/BootImgHeader.kt
index db9201c..09ea51a 100644
--- a/bbootimg/src/main/kotlin/bootimg/BootImgHeader.kt
+++ b/bbootimg/src/main/kotlin/bootimg/BootImgHeader.kt
@@ -13,6 +13,7 @@ import java.nio.ByteOrder
 import java.security.MessageDigest
 import java.util.regex.Pattern
 
+@ExperimentalUnsignedTypes
 open class BootImgHeader(
         var kernelLength: UInt = 0U,
         var kernelOffset: UInt = 0U,
@@ -157,7 +158,7 @@ open class BootImgHeader(
                 val currentFile = File(item)
                 FileInputStream(currentFile).use { iS ->
                     var byteRead: Int
-                    var dataRead = ByteArray(1024)
+                    val dataRead = ByteArray(1024)
                     while (true) {
                         byteRead = iS.read(dataRead)
                         if (-1 == byteRead) {
@@ -189,25 +190,25 @@ open class BootImgHeader(
         if (0U == this.ramdiskLength) {
             param.ramdisk = null
         } else {
-            this.ramdiskLength = File(param.ramdisk).length().toUInt()
+            this.ramdiskLength = File(param.ramdisk!!).length().toUInt()
         }
         //refresh second bootloader size
         if (0U == this.secondBootloaderLength) {
             param.second = null
         } else {
-            this.secondBootloaderLength = File(param.second).length().toUInt()
+            this.secondBootloaderLength = File(param.second!!).length().toUInt()
         }
         //refresh recovery dtbo size
         if (0U == this.recoveryDtboLength) {
             param.dtbo = null
         } else {
-            this.recoveryDtboLength = File(param.dtbo).length().toUInt()
+            this.recoveryDtboLength = File(param.dtbo!!).length().toUInt()
         }
         //refresh recovery dtbo size
         if (0U == this.dtbLength) {
             param.dtb = null
         } else {
-            this.dtbLength = File(param.dtb).length().toUInt()
+            this.dtbLength = File(param.dtb!!).length().toUInt()
         }
 
         //refresh image hash
@@ -230,44 +231,43 @@ open class BootImgHeader(
 
     fun encode(): ByteArray {
         this.refresh()
-        val ret = Struct3(FORMAT_STRING).pack(
+        return Struct3(FORMAT_STRING).pack(
                 "ANDROID!",
                 //10I
-                this.kernelLength,
-                this.kernelOffset,
-                this.ramdiskLength,
-                this.ramdiskOffset,
-                this.secondBootloaderLength,
-                this.secondBootloaderOffset,
-                this.tagsOffset,
-                this.pageSize,
-                this.headerVersion,
-                (packOsVersion(this.osVersion) shl 11) or packOsPatchLevel(this.osPatchLevel),
+                kernelLength,
+                kernelOffset,
+                ramdiskLength,
+                ramdiskOffset,
+                secondBootloaderLength,
+                secondBootloaderOffset,
+                tagsOffset,
+                pageSize,
+                headerVersion,
+                (packOsVersion(osVersion) shl 11) or packOsPatchLevel(osPatchLevel),
                 //16s
-                this.board,
+                board,
                 //512s
-                this.cmdline.substring(0, minOf(512, this.cmdline.length)),
+                cmdline.substring(0, minOf(512, cmdline.length)),
                 //32b
-                this.hash!!,
+                hash!!,
                 //1024s
-                if (this.cmdline.length > 512) this.cmdline.substring(512) else "",
+                if (cmdline.length > 512) cmdline.substring(512) else "",
                 //I
-                this.recoveryDtboLength,
+                recoveryDtboLength,
                 //Q
-                if (this.headerVersion > 0U) this.recoveryDtboOffset else 0,
+                if (headerVersion > 0U) recoveryDtboOffset else 0,
                 //I
-                when (this.headerVersion) {
+                when (headerVersion) {
                     0U -> 0
                     1U -> BOOT_IMAGE_HEADER_V1_SIZE
                     2U -> BOOT_IMAGE_HEADER_V2_SIZE
-                    else -> java.lang.IllegalArgumentException("headerVersion ${this.headerVersion} illegal")
+                    else -> java.lang.IllegalArgumentException("headerVersion $headerVersion illegal")
                 },
                 //I
-                this.dtbLength,
+                dtbLength,
                 //Q
-                if (this.headerVersion > 1U) this.dtbOffset else 0
+                if (headerVersion > 1U) dtbOffset else 0
         )
-        return ret
     }
 
     companion object {
diff --git a/bbootimg/src/main/kotlin/bootimg/BootImgInfo.kt b/bbootimg/src/main/kotlin/bootimg/BootImgInfo.kt
index 561ba58..0c53a94 100644
--- a/bbootimg/src/main/kotlin/bootimg/BootImgInfo.kt
+++ b/bbootimg/src/main/kotlin/bootimg/BootImgInfo.kt
@@ -4,6 +4,7 @@ import cfig.ParamConfig
 import org.apache.commons.exec.CommandLine
 import java.io.InputStream
 
+@ExperimentalUnsignedTypes
 class BootImgInfo(iS: InputStream?) : BootImgHeader(iS) {
     constructor() : this(null)
 
diff --git a/bbootimg/src/main/kotlin/bootimg/Packer.kt b/bbootimg/src/main/kotlin/bootimg/Packer.kt
index 04c388c..d124942 100644
--- a/bbootimg/src/main/kotlin/bootimg/Packer.kt
+++ b/bbootimg/src/main/kotlin/bootimg/Packer.kt
@@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.ObjectMapper
 import org.apache.commons.exec.CommandLine
 import org.apache.commons.exec.DefaultExecutor
 import org.apache.commons.exec.PumpStreamHandler
-import org.junit.Assert
 import org.junit.Assert.assertTrue
 import org.slf4j.LoggerFactory
 import java.io.*
@@ -13,9 +12,9 @@ import java.nio.ByteBuffer
 import java.nio.ByteOrder
 import java.security.MessageDigest
 
+@ExperimentalUnsignedTypes
 class Packer {
     private val log = LoggerFactory.getLogger("Packer")
-    private val workDir = UnifiedConfig.workDir
 
     @Throws(CloneNotSupportedException::class)
     private fun hashFileAndSize(vararg inFiles: String?): ByteArray {
@@ -30,7 +29,7 @@ class Packer {
                 val currentFile = File(item)
                 FileInputStream(currentFile).use { iS ->
                     var byteRead: Int
-                    var dataRead = ByteArray(1024)
+                    val dataRead = ByteArray(1024)
                     while (true) {
                         byteRead = iS.read(dataRead)
                         if (-1 == byteRead) {
@@ -51,7 +50,7 @@ class Packer {
     }
 
     private fun writePaddedFile(inBF: ByteBuffer, srcFile: String, padding: UInt) {
-        Assert.assertTrue(padding < Int.MAX_VALUE.toUInt())
+        assertTrue(padding < Int.MAX_VALUE.toUInt())
         writePaddedFile(inBF, srcFile, padding.toInt())
     }
 
@@ -70,11 +69,6 @@ class Packer {
         }
     }
 
-    private fun padFile(inBF: ByteBuffer, padding: UInt) {
-        Assert.assertTrue(padding < Int.MAX_VALUE.toUInt())
-        padFile(inBF, padding.toInt())
-    }
-
     private fun padFile(inBF: ByteBuffer, padding: Int) {
         val pad = padding - (inBF.position() and padding - 1) and padding - 1
         inBF.put(ByteArray(pad))
@@ -101,12 +95,12 @@ class Packer {
             writePaddedFile(bf, param.dtb!!, info2.pageSize)
         }
         //write
-        FileOutputStream(outputFile + ".clear", true).use { fos ->
+        FileOutputStream("$outputFile.clear", true).use { fos ->
             fos.write(bf.array(), 0, bf.position())
         }
     }
 
-    fun packRootfs(mkbootfs: String) {
+    private fun packRootfs(mkbootfs: String) {
         val param = ParamConfig()
         log.info("Packing rootfs ${UnifiedConfig.workDir}root ...")
         val outputStream = ByteArrayOutputStream()
@@ -143,11 +137,11 @@ class Packer {
         File("${UnifiedConfig.workDir}ramdisk.img").deleleIfExists()
 
         if (info2.ramdiskLength > 0U) {
-            if (File(param.ramdisk).exists() && !File(UnifiedConfig.workDir + "root").exists()) {
+            if (File(param.ramdisk!!).exists() && !File(UnifiedConfig.workDir + "root").exists()) {
                 //do nothing if we have ramdisk.img.gz but no /root
                 log.warn("Use prebuilt ramdisk file: ${param.ramdisk}")
             } else {
-                File(param.ramdisk).deleleIfExists()
+                File(param.ramdisk!!).deleleIfExists()
                 packRootfs(mkbootfsBin)
             }
         }
@@ -175,18 +169,4 @@ class Packer {
             throw UnknownError("Do not know why hash verification fails, maybe a bug")
         }
     }
-
-    private fun runCmdList(inCmd: List<String>, inWorkdir: String? = null) {
-        log.info("CMD:$inCmd")
-        val pb = ProcessBuilder(inCmd)
-                .directory(File(inWorkdir ?: "."))
-                .redirectErrorStream(true)
-        val p: Process = pb.start()
-        val br = BufferedReader(InputStreamReader(p.inputStream))
-        while (br.ready()) {
-            log.info(br.readLine())
-        }
-        p.waitFor()
-        assertTrue(0 == p.exitValue())
-    }
 }
diff --git a/bbootimg/src/main/kotlin/bootimg/Parser.kt b/bbootimg/src/main/kotlin/bootimg/Parser.kt
index 6bd31b0..5734a27 100644
--- a/bbootimg/src/main/kotlin/bootimg/Parser.kt
+++ b/bbootimg/src/main/kotlin/bootimg/Parser.kt
@@ -4,18 +4,13 @@ import cfig.bootimg.BootImgInfo
 import cfig.dtb_util.DTC
 import cfig.kernel_util.KernelExtractor
 import com.fasterxml.jackson.databind.ObjectMapper
-import de.vandermeer.asciitable.AsciiTable
 import org.apache.commons.exec.CommandLine
 import org.apache.commons.exec.DefaultExecutor
-import org.junit.Assert.assertTrue
 import org.slf4j.LoggerFactory
 import java.io.File
 import java.io.FileInputStream
-import java.io.InputStream
-import java.lang.IllegalArgumentException
-import java.nio.ByteBuffer
-import java.nio.ByteOrder
 
+@ExperimentalUnsignedTypes
 class Parser {
     private fun verifiedWithAVB(fileName: String): Boolean {
         val expectedBf = "AVBf".toByteArray()
@@ -58,7 +53,7 @@ class Parser {
         return info2
     }
 
-    fun parseKernelInfo(kernelFile: String) {
+    private fun parseKernelInfo(kernelFile: String) {
         val ke = KernelExtractor()
         if (ke.envCheck()) {
             ke.run(kernelFile, File("."))
@@ -164,56 +159,5 @@ class Parser {
                 throw IllegalArgumentException("$fileName failed integrity check by \"$cmdline\"")
             }
         }
-
-        fun readShort(iS: InputStream): Short {
-            val bf = ByteBuffer.allocate(128)
-            bf.order(ByteOrder.LITTLE_ENDIAN)
-            val data2 = ByteArray(2)
-            assertTrue(2 == iS.read(data2))
-            bf.clear()
-            bf.put(data2)
-            bf.flip()
-            return bf.short
-        }
-
-        fun readInt(iS: InputStream): Int {
-            val bf = ByteBuffer.allocate(128)
-            bf.order(ByteOrder.LITTLE_ENDIAN)
-            val data4 = ByteArray(4)
-            assertTrue(4 == iS.read(data4))
-            bf.clear()
-            bf.put(data4)
-            bf.flip()
-            return bf.int
-        }
-
-        fun readUnsignedAsLong(iS: InputStream): Long {
-            val bf = ByteBuffer.allocate(128)
-            bf.order(ByteOrder.LITTLE_ENDIAN)
-            val data4 = ByteArray(4)
-            assertTrue(4 == iS.read(data4))
-            bf.clear()
-            bf.put(data4)
-            bf.put(ByteArray(4)) //complete high bits with 0
-            bf.flip()
-            return bf.long
-        }
-
-        fun readLong(iS: InputStream): Long {
-            val bf = ByteBuffer.allocate(128)
-            bf.order(ByteOrder.LITTLE_ENDIAN)
-            val data4 = ByteArray(8)
-            assertTrue(8 == iS.read(data4))
-            bf.clear()
-            bf.put(data4)
-            bf.flip()
-            return bf.long
-        }
-
-        fun readBytes(iS: InputStream, len: Int): ByteArray {
-            val data4 = ByteArray(len)
-            assertTrue(len == iS.read(data4))
-            return data4
-        }
     }
 }
diff --git a/bbootimg/src/main/kotlin/bootloader_message/BootloaderMsg.kt b/bbootimg/src/main/kotlin/bootloader_message/BootloaderMsg.kt
index 3f9af00..a1bde11 100644
--- a/bbootimg/src/main/kotlin/bootloader_message/BootloaderMsg.kt
+++ b/bbootimg/src/main/kotlin/bootloader_message/BootloaderMsg.kt
@@ -8,6 +8,7 @@ import java.io.FileInputStream
 import java.io.FileOutputStream
 import java.lang.IllegalStateException
 
+@ExperimentalUnsignedTypes
 data class BootloaderMsg(
         var command: String = "",
         var status: String = "",
diff --git a/bbootimg/src/main/kotlin/cfig/io/Struct3.kt b/bbootimg/src/main/kotlin/cfig/io/Struct3.kt
index 2fa3789..71dd6da 100644
--- a/bbootimg/src/main/kotlin/cfig/io/Struct3.kt
+++ b/bbootimg/src/main/kotlin/cfig/io/Struct3.kt
@@ -5,12 +5,12 @@ import org.junit.Assert
 import org.slf4j.LoggerFactory
 import java.io.IOException
 import java.io.InputStream
-import java.net.URLStreamHandler
 import java.nio.ByteBuffer
 import java.nio.ByteOrder
 import java.util.*
 import java.util.regex.Pattern
 
+@ExperimentalUnsignedTypes
 class Struct3 {
     private val log = LoggerFactory.getLogger(Struct3::class.java)
     private val formatString: String
@@ -207,7 +207,7 @@ class Struct3 {
                 Assert.assertTrue("[$arg](${arg!!::class.java}) is NOT instance of ByteArray/IntArray",
                         arg is ByteArray || arg is IntArray || arg is UByteArray)
                 val argInternal = if (arg is IntArray) {
-                    var arg2: MutableList<Byte> = mutableListOf()
+                    val arg2: MutableList<Byte> = mutableListOf()
                     for (item in arg) {
                         Assert.assertTrue("$item is not valid UByte",
                                 item in UByte.MIN_VALUE.toInt()..UByte.MAX_VALUE.toInt())
diff --git a/bbootimg/src/main/kotlin/init/Reboot.kt b/bbootimg/src/main/kotlin/init/Reboot.kt
index 2a493bd..db56459 100644
--- a/bbootimg/src/main/kotlin/init/Reboot.kt
+++ b/bbootimg/src/main/kotlin/init/Reboot.kt
@@ -12,6 +12,7 @@ class Reboot {
         ANDROID_RB_THERMOFF
     }
 
+    @ExperimentalUnsignedTypes
     companion object {
         private val log = LoggerFactory.getLogger(Reboot::class.java)
         const val dynamicPartitionKey = "ro.boot.dynamic_partitions"
diff --git a/bbootimg/src/main/kotlin/packable/BootImgParser.kt b/bbootimg/src/main/kotlin/packable/BootImgParser.kt
index b651c2d..48ebcbb 100644
--- a/bbootimg/src/main/kotlin/packable/BootImgParser.kt
+++ b/bbootimg/src/main/kotlin/packable/BootImgParser.kt
@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory
 import java.io.File
 import java.lang.IllegalArgumentException
 
+@ExperimentalUnsignedTypes
 class BootImgParser : IPackable {
     private val log = LoggerFactory.getLogger(BootImgParser::class.java)
 
diff --git a/bbootimg/src/main/kotlin/packable/DtboParser.kt b/bbootimg/src/main/kotlin/packable/DtboParser.kt
index f3aeba0..d6c6cb2 100644
--- a/bbootimg/src/main/kotlin/packable/DtboParser.kt
+++ b/bbootimg/src/main/kotlin/packable/DtboParser.kt
@@ -10,6 +10,7 @@ import java.io.File
 import java.io.FileInputStream
 import java.util.*
 
+@ExperimentalUnsignedTypes
 class DtboParser(val workDir: File) : IPackable {
     constructor() : this(File("."))
 
@@ -59,14 +60,14 @@ class DtboParser(val workDir: File) : IPackable {
             return
         }
 
-        val headerPath = File("${UnifiedConfig.workDir}/dtbo.header").path!!
+        val headerPath = File("${UnifiedConfig.workDir}/dtbo.header").path
         val props = Properties()
         props.load(FileInputStream(File(headerPath)))
         val cmd = CommandLine.parse("external/mkdtboimg.py create $fileName.clear").let {
             it.addArguments("--version=1")
             for (i in 0 until Integer.parseInt(props.getProperty("dt_entry_count"))) {
                 val dtsName = File(UnifiedConfig.workDir + "/dtb.$i").path
-                it.addArguments("$dtsName")
+                it.addArguments(dtsName)
             }
             it
         }
diff --git a/bbootimg/src/main/kotlin/packable/PackableLauncher.kt b/bbootimg/src/main/kotlin/packable/PackableLauncher.kt
index 179d46a..ce30bf0 100644
--- a/bbootimg/src/main/kotlin/packable/PackableLauncher.kt
+++ b/bbootimg/src/main/kotlin/packable/PackableLauncher.kt
@@ -9,10 +9,12 @@ import kotlin.reflect.full.createInstance
 
 class PackableLauncher
 
+@ExperimentalUnsignedTypes
 fun main(args: Array<String>) {
     val log = LoggerFactory.getLogger(PackableLauncher::class.java)
     val packablePool = mutableMapOf<List<String>, KClass<IPackable>>()
     listOf(DtboParser(), VBMetaParser(), BootImgParser()).forEach {
+        @Suppress("UNCHECKED_CAST")
         packablePool.put(it.capabilities(), it::class as KClass<IPackable>)
     }
     packablePool.forEach {
diff --git a/bbootimg/src/main/kotlin/packable/VBMetaParser.kt b/bbootimg/src/main/kotlin/packable/VBMetaParser.kt
index 87e3497..7cde985 100644
--- a/bbootimg/src/main/kotlin/packable/VBMetaParser.kt
+++ b/bbootimg/src/main/kotlin/packable/VBMetaParser.kt
@@ -2,6 +2,7 @@ package cfig.packable
 
 import cfig.Avb
 
+@ExperimentalUnsignedTypes
 class VBMetaParser: IPackable {
     override fun capabilities(): List<String> {
         return listOf("^vbmeta\\.img$")
diff --git a/bbootimg/src/test/kotlin/AvbTest.kt b/bbootimg/src/test/kotlin/AvbTest.kt
index e93b49c..d0a4bf8 100644
--- a/bbootimg/src/test/kotlin/AvbTest.kt
+++ b/bbootimg/src/test/kotlin/AvbTest.kt
@@ -7,6 +7,7 @@ import org.junit.Assert.*
 import org.slf4j.LoggerFactory
 import java.io.ByteArrayInputStream
 
+@ExperimentalUnsignedTypes
 class AvbTest {
     private val log = LoggerFactory.getLogger(AvbTest::class.java)
 
diff --git a/bbootimg/src/test/kotlin/HelperTest.kt b/bbootimg/src/test/kotlin/HelperTest.kt
index 756496b..f637033 100644
--- a/bbootimg/src/test/kotlin/HelperTest.kt
+++ b/bbootimg/src/test/kotlin/HelperTest.kt
@@ -23,6 +23,7 @@ import java.security.spec.RSAPrivateKeySpec
 import java.security.PrivateKey
 
 
+@ExperimentalUnsignedTypes
 class HelperTest {
     @Test
     fun rawSignTest() {
@@ -53,7 +54,7 @@ class HelperTest {
         println("data size " + data.size)
         println(signature.provider)
         val sig = signature.sign()
-//        assertEquals(expectedSig, Hex.encodeHexString(sig))
+        println(sig)
     }
 
     @Test
@@ -79,6 +80,7 @@ class HelperTest {
         val kf = KeyFactory.getInstance("rsa")
         val privk = kf.generatePrivate(pk8Spec)
         val pubk = kf.generatePublic(x509Spec)
+        println(pubk)
 
         val cipher = Cipher.getInstance("RSA").apply {
             this.init(Cipher.ENCRYPT_MODE, privk)
@@ -121,12 +123,5 @@ class HelperTest {
         val clearMsg = BigInteger.valueOf(10)
         val encMsg = clearMsg.pow(e.toInt()).mod(modulus)
         println("clear: $clearMsg, enc: $encMsg")
-        val decMsg = clearMsg
-    }
-
-    fun gcd(a: BigInteger, b: BigInteger): BigInteger {
-        return if (b == BigInteger.ZERO) {
-            a
-        } else gcd(b, a.mod(b))
     }
 }
diff --git a/bbootimg/src/test/kotlin/KeyUtilTest.kt b/bbootimg/src/test/kotlin/KeyUtilTest.kt
index 890a034..57eed5a 100644
--- a/bbootimg/src/test/kotlin/KeyUtilTest.kt
+++ b/bbootimg/src/test/kotlin/KeyUtilTest.kt
@@ -7,6 +7,7 @@ import java.io.FileInputStream
 import java.nio.file.Files
 import java.nio.file.Paths
 
+@ExperimentalUnsignedTypes
 class KeyUtilTest {
     @Test
     fun parseKeys() {
diff --git a/bbootimg/src/test/kotlin/ReadTest.kt b/bbootimg/src/test/kotlin/ReadTest.kt
index 4fde8bc..b833528 100644
--- a/bbootimg/src/test/kotlin/ReadTest.kt
+++ b/bbootimg/src/test/kotlin/ReadTest.kt
@@ -58,7 +58,7 @@ class ReadTest {
                         triggers: MutableList<Trigger>,
                         services: MutableList<Service>) {
         if (!File(inRootDir + inPath).exists()) {
-            println("Parsing $inPath fail: 404");
+            println("Parsing $inPath fail: 404")
             return
         }
         println("Parsing file $inPath ...")
@@ -242,7 +242,7 @@ class ReadTest {
         imports.forEach { println(it) }
 
         //parse imports again
-        var iteratorImport: Iterator<Import> = imports.iterator()
+        val iteratorImport: Iterator<Import> = imports.iterator()
         while (iteratorImport.hasNext()) {
             val item: Import = iteratorImport.next()
             parseConfigFile(inRootDir, item.initrc, triggers, services)
@@ -278,8 +278,7 @@ class ReadTest {
             if (m.find()) {
                 inServices
                         .filter {
-                            it.theClass != null
-                                    && it.theClass!!.split(" ").contains(m.group(1))
+                            it.theClass.split(" ").contains(m.group(1))
                         }
                         .forEach {
                             println(aPre + "|    \\-- Starting " + it.name + "...")
@@ -288,8 +287,8 @@ class ReadTest {
                 println("error")
             }
         } else if (this.startsWith("start")) {
-            println(aPre + "|-- " + this)
-            println(aPre + "|    \\-- Starting " + this.substring(5).trim() + "...")
+            println("$aPre|-- $this")
+            println("""$aPre|    \-- Starting ${this.substring(5).trim()}...""")
         } else {
             println(aPre + "|-- " + this)
         }
diff --git a/bbootimg/src/test/kotlin/avb/BlobTest.kt b/bbootimg/src/test/kotlin/avb/BlobTest.kt
index 32827b5..33ebe14 100644
--- a/bbootimg/src/test/kotlin/avb/BlobTest.kt
+++ b/bbootimg/src/test/kotlin/avb/BlobTest.kt
@@ -5,6 +5,7 @@ import org.apache.commons.codec.binary.Hex
 import org.junit.Assert.assertEquals
 import org.junit.Test
 
+@ExperimentalUnsignedTypes
 class BlobTest {
     @Test
     fun testEncodedKey2048() {
diff --git a/bbootimg/src/test/kotlin/avb/FooterTest.kt b/bbootimg/src/test/kotlin/avb/FooterTest.kt
index 0781284..94822a2 100644
--- a/bbootimg/src/test/kotlin/avb/FooterTest.kt
+++ b/bbootimg/src/test/kotlin/avb/FooterTest.kt
@@ -6,6 +6,7 @@ import org.junit.Test
 import org.junit.Assert.*
 import java.io.ByteArrayInputStream
 
+@ExperimentalUnsignedTypes
 class FooterTest {
 
     @Test
diff --git a/bbootimg/src/test/kotlin/avb/HeaderTest.kt b/bbootimg/src/test/kotlin/avb/HeaderTest.kt
index a92d993..6d520a9 100644
--- a/bbootimg/src/test/kotlin/avb/HeaderTest.kt
+++ b/bbootimg/src/test/kotlin/avb/HeaderTest.kt
@@ -4,6 +4,7 @@ import org.apache.commons.codec.binary.Hex
 import org.junit.Test
 import java.io.ByteArrayInputStream
 
+@ExperimentalUnsignedTypes
 class HeaderTest {
 
     @Test
diff --git a/bbootimg/src/test/kotlin/avb/alg/AlgorithmsTest.kt b/bbootimg/src/test/kotlin/avb/alg/AlgorithmsTest.kt
index f9a3f65..4683a4e 100644
--- a/bbootimg/src/test/kotlin/avb/alg/AlgorithmsTest.kt
+++ b/bbootimg/src/test/kotlin/avb/alg/AlgorithmsTest.kt
@@ -5,6 +5,7 @@ import cfig.Helper
 import org.junit.Assert
 import org.junit.Test
 
+@ExperimentalUnsignedTypes
 class AlgorithmsTest {
     @Test
     fun test1() {
@@ -12,5 +13,6 @@ class AlgorithmsTest {
 
         Assert.assertEquals(Helper.toHexString(Algorithms.get("SHA256_RSA4096")!!.padding),
                 "0001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff003031300d060960864801650304020105000420")
+        println(alg)
     }
 }
\ No newline at end of file
diff --git a/bbootimg/src/test/kotlin/avb/desc/HashDescriptorTest.kt b/bbootimg/src/test/kotlin/avb/desc/HashDescriptorTest.kt
index 24c94aa..95de672 100644
--- a/bbootimg/src/test/kotlin/avb/desc/HashDescriptorTest.kt
+++ b/bbootimg/src/test/kotlin/avb/desc/HashDescriptorTest.kt
@@ -6,6 +6,7 @@ import org.junit.Test
 import org.slf4j.LoggerFactory
 import java.io.ByteArrayInputStream
 
+@ExperimentalUnsignedTypes
 class HashDescriptorTest {
     private val log = LoggerFactory.getLogger(HashDescriptorTest::class.java)
 
diff --git a/bbootimg/src/test/kotlin/avb/desc/HashTreeDescriptorTest.kt b/bbootimg/src/test/kotlin/avb/desc/HashTreeDescriptorTest.kt
index 3a6d4b7..42ef0f7 100644
--- a/bbootimg/src/test/kotlin/avb/desc/HashTreeDescriptorTest.kt
+++ b/bbootimg/src/test/kotlin/avb/desc/HashTreeDescriptorTest.kt
@@ -7,6 +7,7 @@ import org.junit.Test
 import org.junit.Assert.*
 import java.io.ByteArrayInputStream
 
+@ExperimentalUnsignedTypes
 class HashTreeDescriptorTest {
 
     @Test
diff --git a/bbootimg/src/test/kotlin/avb/desc/KernelCmdlineDescriptorTest.kt b/bbootimg/src/test/kotlin/avb/desc/KernelCmdlineDescriptorTest.kt
index 1e83327..f3a8fe5 100644
--- a/bbootimg/src/test/kotlin/avb/desc/KernelCmdlineDescriptorTest.kt
+++ b/bbootimg/src/test/kotlin/avb/desc/KernelCmdlineDescriptorTest.kt
@@ -5,6 +5,7 @@ import org.junit.Assert.assertEquals
 import org.junit.Test
 import java.io.ByteArrayInputStream
 
+@ExperimentalUnsignedTypes
 class KernelCmdlineDescriptorTest {
     @Test
     fun encode() {
diff --git a/bbootimg/src/test/kotlin/avb/desc/UnknownDescriptorTest.kt b/bbootimg/src/test/kotlin/avb/desc/UnknownDescriptorTest.kt
index d814c62..a4736f0 100644
--- a/bbootimg/src/test/kotlin/avb/desc/UnknownDescriptorTest.kt
+++ b/bbootimg/src/test/kotlin/avb/desc/UnknownDescriptorTest.kt
@@ -6,6 +6,7 @@ import org.junit.Test
 import org.slf4j.LoggerFactory
 import java.io.ByteArrayInputStream
 
+@ExperimentalUnsignedTypes
 class UnknownDescriptorTest {
     private val log = LoggerFactory.getLogger(UnknownDescriptorTest::class.java)
 
diff --git a/bbootimg/src/test/kotlin/bootloader_message/BootloaderMsgTest.kt b/bbootimg/src/test/kotlin/bootloader_message/BootloaderMsgTest.kt
index 20c93db..c2a405a 100644
--- a/bbootimg/src/test/kotlin/bootloader_message/BootloaderMsgTest.kt
+++ b/bbootimg/src/test/kotlin/bootloader_message/BootloaderMsgTest.kt
@@ -6,6 +6,7 @@ import org.junit.Test
 import org.junit.Assert.*
 import org.slf4j.LoggerFactory
 
+@ExperimentalUnsignedTypes
 class BootloaderMsgTest {
     private val log = LoggerFactory.getLogger(BootloaderMsgTest::class.java)
 
diff --git a/bbootimg/src/test/kotlin/cfig/io/Struct3Test.kt b/bbootimg/src/test/kotlin/cfig/io/Struct3Test.kt
index 1a67036..96fbd46 100644
--- a/bbootimg/src/test/kotlin/cfig/io/Struct3Test.kt
+++ b/bbootimg/src/test/kotlin/cfig/io/Struct3Test.kt
@@ -2,10 +2,10 @@ import cfig.Helper
 import cfig.io.Struct3
 import com.fasterxml.jackson.databind.ObjectMapper
 import org.junit.Assert
-import org.junit.Assert.*
 import org.junit.Test
 import java.io.ByteArrayInputStream
 
+@ExperimentalUnsignedTypes
 class Struct3Test {
     private fun getConvertedFormats(inStruct: Struct3): ArrayList<Map<String, Int>> {
         val f = inStruct.javaClass.getDeclaredField("formats")
@@ -13,7 +13,8 @@ class Struct3Test {
         val formatDumps = arrayListOf<Map<String, Int>>()
         (f.get(inStruct) as ArrayList<*>).apply {
             this.forEach {
-                val format = it as Array<Object>
+                @Suppress("UNCHECKED_CAST")
+                val format = it as Array<Any>
                 val k = if (format[0].toString().indexOf(" ") > 0) {
                     format[0].toString().split(" ")[1]
                 } else {
@@ -373,10 +374,10 @@ class Struct3Test {
     @Test
     fun legacyTest() {
         Assert.assertTrue(Struct3("<2i4b4b").pack(
-                1, 7321, byteArrayOf(1, 2, 3, 4), byteArrayOf(200.toByte(), 201.toByte(), 202.toByte(), 203.toByte()))!!
+                1, 7321, byteArrayOf(1, 2, 3, 4), byteArrayOf(200.toByte(), 201.toByte(), 202.toByte(), 203.toByte()))
                 .contentEquals(Helper.fromHexString("01000000991c000001020304c8c9cacb")))
         Assert.assertTrue(Struct3("<2i4b4B").pack(
-                1, 7321, byteArrayOf(1, 2, 3, 4), intArrayOf(200, 201, 202, 203))!!
+                1, 7321, byteArrayOf(1, 2, 3, 4), intArrayOf(200, 201, 202, 203))
                 .contentEquals(Helper.fromHexString("01000000991c000001020304c8c9cacb")))
 
         Assert.assertTrue(Struct3("b2x").pack(byteArrayOf(0x13), null).contentEquals(Helper.fromHexString("130000")))
@@ -390,20 +391,20 @@ class Struct3Test {
     @Test
     fun legacyIntegerLE() {
         //int (4B)
-        assertTrue(Struct3("<2i").pack(1, 7321).contentEquals(Helper.fromHexString("01000000991c0000")))
+        Assert.assertTrue(Struct3("<2i").pack(1, 7321).contentEquals(Helper.fromHexString("01000000991c0000")))
         val ret = Struct3("<2i").unpack(ByteArrayInputStream(Helper.fromHexString("01000000991c0000")))
-        assertEquals(2, ret.size)
-        assertTrue(ret[0] is Int)
-        assertTrue(ret[1] is Int)
-        assertEquals(1, ret[0] as Int)
-        assertEquals(7321, ret[1] as Int)
+        Assert.assertEquals(2, ret.size)
+        Assert.assertTrue(ret[0] is Int)
+        Assert.assertTrue(ret[1] is Int)
+        Assert.assertEquals(1, ret[0] as Int)
+        Assert.assertEquals(7321, ret[1] as Int)
 
         //unsigned int (4B)
-        assertTrue(Struct3("<I").pack(2L).contentEquals(Helper.fromHexString("02000000")))
-        assertTrue(Struct3("<I").pack(2).contentEquals(Helper.fromHexString("02000000")))
+        Assert.assertTrue(Struct3("<I").pack(2L).contentEquals(Helper.fromHexString("02000000")))
+        Assert.assertTrue(Struct3("<I").pack(2).contentEquals(Helper.fromHexString("02000000")))
         //greater than Int.MAX_VALUE
-        assertTrue(Struct3("<I").pack(2147483748L).contentEquals(Helper.fromHexString("64000080")))
-        assertTrue(Struct3("<I").pack(2147483748).contentEquals(Helper.fromHexString("64000080")))
+        Assert.assertTrue(Struct3("<I").pack(2147483748L).contentEquals(Helper.fromHexString("64000080")))
+        Assert.assertTrue(Struct3("<I").pack(2147483748).contentEquals(Helper.fromHexString("64000080")))
         try {
             Struct3("<I").pack(-12)
             throw Exception("should not reach here")
@@ -412,22 +413,22 @@ class Struct3Test {
         }
 
         //negative int
-        assertTrue(Struct3("<i").pack(-333).contentEquals(Helper.fromHexString("b3feffff")))
+        Assert.assertTrue(Struct3("<i").pack(-333).contentEquals(Helper.fromHexString("b3feffff")))
     }
 
     @Test
     fun legacyIntegerBE() {
         run {
-            assertTrue(Struct3(">2i").pack(1, 7321).contentEquals(Helper.fromHexString("0000000100001c99")))
+            Assert.assertTrue(Struct3(">2i").pack(1, 7321).contentEquals(Helper.fromHexString("0000000100001c99")))
             val ret = Struct3(">2i").unpack(ByteArrayInputStream(Helper.fromHexString("0000000100001c99")))
-            assertEquals(1, ret[0] as Int)
-            assertEquals(7321, ret[1] as Int)
+            Assert.assertEquals(1, ret[0] as Int)
+            Assert.assertEquals(7321, ret[1] as Int)
         }
 
         run {
-            assertTrue(Struct3("!i").pack(-333).contentEquals(Helper.fromHexString("fffffeb3")))
+            Assert.assertTrue(Struct3("!i").pack(-333).contentEquals(Helper.fromHexString("fffffeb3")))
             val ret2 = Struct3("!i").unpack(ByteArrayInputStream(Helper.fromHexString("fffffeb3")))
-            assertEquals(-333, ret2[0] as Int)
+            Assert.assertEquals(-333, ret2[0] as Int)
         }
     }
 }
diff --git a/bbootimg/src/test/kotlin/cfig/io/StructTest.kt b/bbootimg/src/test/kotlin/cfig/io/StructTest.kt
index b513e07..7bbe8e0 100644
--- a/bbootimg/src/test/kotlin/cfig/io/StructTest.kt
+++ b/bbootimg/src/test/kotlin/cfig/io/StructTest.kt
@@ -7,6 +7,7 @@ import org.junit.Assert.*
 import java.io.ByteArrayInputStream
 import kotlin.reflect.jvm.jvmName
 
+@ExperimentalUnsignedTypes
 class StructTest {
     private fun getConvertedFormats(inStruct: Struct): ArrayList<Map<String, Int>> {
         val f = inStruct.javaClass.getDeclaredField("formats")
@@ -14,7 +15,8 @@ class StructTest {
         val formatDumps = arrayListOf<Map<String, Int>>()
         (f.get(inStruct) as ArrayList<*>).apply {
             this.forEach {
-                val format = it as Array<Object>
+                @Suppress("UNCHECKED_CAST")
+                val format = it as Array<Any>
                 formatDumps.add(mapOf(format[0].toString().split(" ")[1] to (format[1] as Int)))
             }
         }
@@ -52,7 +54,7 @@ class StructTest {
     @Test
     fun integerLE() {
         //int (4B)
-        assertTrue(Struct("<2i").pack(1, 7321).contentEquals(Helper.fromHexString("01000000991c0000")))
+        assertTrue(Struct("<2i").pack(1, 7321)!!.contentEquals(Helper.fromHexString("01000000991c0000")))
         val ret = Struct("<2i").unpack(ByteArrayInputStream(Helper.fromHexString("01000000991c0000")))
         assertEquals(2, ret.size)
         assertTrue(ret[0] is Int)
@@ -61,11 +63,11 @@ class StructTest {
         assertEquals(7321, ret[1] as Int)
 
         //unsigned int (4B)
-        assertTrue(Struct("<I").pack(2L).contentEquals(Helper.fromHexString("02000000")))
-        assertTrue(Struct("<I").pack(2).contentEquals(Helper.fromHexString("02000000")))
+        assertTrue(Struct("<I").pack(2L)!!.contentEquals(Helper.fromHexString("02000000")))
+        assertTrue(Struct("<I").pack(2)!!.contentEquals(Helper.fromHexString("02000000")))
         //greater than Int.MAX_VALUE
-        assertTrue(Struct("<I").pack(2147483748L).contentEquals(Helper.fromHexString("64000080")))
-        assertTrue(Struct("<I").pack(2147483748).contentEquals(Helper.fromHexString("64000080")))
+        assertTrue(Struct("<I").pack(2147483748L)!!.contentEquals(Helper.fromHexString("64000080")))
+        assertTrue(Struct("<I").pack(2147483748)!!.contentEquals(Helper.fromHexString("64000080")))
         try {
             Struct("<I").pack(-12)
             throw Exception("should not reach here")
@@ -73,20 +75,20 @@ class StructTest {
         }
 
         //negative int
-        assertTrue(Struct("<i").pack(-333).contentEquals(Helper.fromHexString("b3feffff")))
+        assertTrue(Struct("<i").pack(-333)!!.contentEquals(Helper.fromHexString("b3feffff")))
     }
 
     @Test
     fun integerBE() {
         run {
-            assertTrue(Struct(">2i").pack(1, 7321).contentEquals(Helper.fromHexString("0000000100001c99")))
+            assertTrue(Struct(">2i").pack(1, 7321)!!.contentEquals(Helper.fromHexString("0000000100001c99")))
             val ret = Struct(">2i").unpack(ByteArrayInputStream(Helper.fromHexString("0000000100001c99")))
             assertEquals(1, ret[0] as Int)
             assertEquals(7321, ret[1] as Int)
         }
 
         run {
-            assertTrue(Struct("!i").pack(-333).contentEquals(Helper.fromHexString("fffffeb3")))
+            assertTrue(Struct("!i").pack(-333)!!.contentEquals(Helper.fromHexString("fffffeb3")))
             val ret2 = Struct("!i").unpack(ByteArrayInputStream(Helper.fromHexString("fffffeb3")))
             assertEquals(-333, ret2[0] as Int)
         }
@@ -95,8 +97,8 @@ class StructTest {
     @Test
     fun byteArrayTest() {
         //byte array
-        assertTrue(Struct("<4b").pack(byteArrayOf(-128, 2, 55, 127)).contentEquals(Helper.fromHexString("8002377f")))
-        assertTrue(Struct("<4b").pack(intArrayOf(0, 55, 202, 0xff)).contentEquals(Helper.fromHexString("0037caff")))
+        assertTrue(Struct("<4b").pack(byteArrayOf(-128, 2, 55, 127))!!.contentEquals(Helper.fromHexString("8002377f")))
+        assertTrue(Struct("<4b").pack(intArrayOf(0, 55, 202, 0xff))!!.contentEquals(Helper.fromHexString("0037caff")))
         try {
             Struct("b").pack(intArrayOf(256))
             throw Exception("should not reach here")
@@ -121,13 +123,13 @@ class StructTest {
 
     @Test
     fun paddingTest() {
-        assertTrue(Struct("b2x").pack(byteArrayOf(0x13), null).contentEquals(Helper.fromHexString("130000")))
-        assertTrue(Struct("b2xi").pack(byteArrayOf(0x13), null, 55).contentEquals(Helper.fromHexString("13000037000000")))
+        assertTrue(Struct("b2x").pack(byteArrayOf(0x13), null)!!.contentEquals(Helper.fromHexString("130000")))
+        assertTrue(Struct("b2xi").pack(byteArrayOf(0x13), null, 55)!!.contentEquals(Helper.fromHexString("13000037000000")))
     }
 
     @Test
     fun stringTest() {
-        Struct("5s").pack("Good".toByteArray()).contentEquals(Helper.fromHexString("476f6f6400"))
-        Struct("5s1b").pack("Good".toByteArray(), byteArrayOf(13)).contentEquals(Helper.fromHexString("476f6f64000d"))
+        Struct("5s").pack("Good".toByteArray())!!.contentEquals(Helper.fromHexString("476f6f6400"))
+        Struct("5s1b").pack("Good".toByteArray(), byteArrayOf(13))!!.contentEquals(Helper.fromHexString("476f6f64000d"))
     }
 }
diff --git a/bbootimg/src/test/kotlin/init/RebootTest.kt b/bbootimg/src/test/kotlin/init/RebootTest.kt
index f77e918..b548b83 100644
--- a/bbootimg/src/test/kotlin/init/RebootTest.kt
+++ b/bbootimg/src/test/kotlin/init/RebootTest.kt
@@ -1,10 +1,10 @@
 package init
 
 import cfig.init.Reboot
-import org.junit.Assert.*
 import org.junit.Test
 import java.util.*
 
+@ExperimentalUnsignedTypes
 class RebootTest {
     @Test
     fun testDifferentModes() {