diff --git a/bbootimg/src/main/kotlin/avb/Avb.kt b/bbootimg/src/main/kotlin/avb/Avb.kt
index a8e01a1..2185a08 100644
--- a/bbootimg/src/main/kotlin/avb/Avb.kt
+++ b/bbootimg/src/main/kotlin/avb/Avb.kt
@@ -206,7 +206,7 @@ class Avb {
                 val readBackInfo = ObjectMapper().readValue(File(getJsonFileName(fileName)), AVBInfo::class.java)
                 val intermediateDir = Helper.joinPath(Helper.prop("workDir")!!, "intermediate")
                 val newHashDesc = if (File(intermediateDir).exists()) {
-                    AVBInfo.parseFrom(Dumpling(Helper.joinPath(intermediateDir, "$fileName.signed")))
+                    AVBInfo.parseFrom(Dumpling(Helper.joinPath(intermediateDir, File("$fileName.signed").name)))
                 } else {
                     //FIXME: before BootV2 supports abe mode
                     AVBInfo.parseFrom(Dumpling("$fileName.signed"))
diff --git a/bbootimg/src/main/kotlin/rom/sparse/SparseImage.kt b/bbootimg/src/main/kotlin/rom/sparse/SparseImage.kt
index c3ae20c..9bdbbe5 100644
--- a/bbootimg/src/main/kotlin/rom/sparse/SparseImage.kt
+++ b/bbootimg/src/main/kotlin/rom/sparse/SparseImage.kt
@@ -34,7 +34,7 @@ data class SparseImage(var info: SparseInfo = SparseInfo()) {
                     partName,
                     workDir,
                     File(workDir, File(info.output).nameWithoutExtension).path,
-                    File(workDir, File(info.pulp).name + ".signed").path
+                    File(Helper.prop("intermediateDir"), File(info.pulp).name + ".signed").path
                 )
             }
 
@@ -44,7 +44,7 @@ data class SparseImage(var info: SparseInfo = SparseInfo()) {
                     partName,
                     workDir,
                     File(workDir, File(info.output).nameWithoutExtension).path,
-                    File(workDir, "${info.output}.signed").path
+                    File(Helper.prop("intermediateDir"), "${info.output}.signed").path
                 )
             }
 
@@ -119,7 +119,7 @@ data class SparseImage(var info: SparseInfo = SparseInfo()) {
         if (info.outerFsType == "sparse") {
             img2simg(File(workDir, (File(info.output).name + ".signed")).path, File(info.output).name + ".signed")
         } else {
-            val s = info.pulp + ".signed"
+            val s = Helper.joinPath(Helper.prop("intermediateDir")!!, File(info.pulp + ".signed").name)
             val t = info.output + ".signed"
             log.info("Moving $s -> $t")
             Files.move(Path(s), Path(t), java.nio.file.StandardCopyOption.REPLACE_EXISTING)
@@ -261,7 +261,7 @@ data class SparseImage(var info: SparseInfo = SparseInfo()) {
             DefaultExecutor().apply {
                 streamHandler = PumpStreamHandler(System.out, System.err)
             }.execute(CommandLine.parse("aosp/plugged/bin/sefcontext_compile").apply {
-                addArguments("-o " + Helper.prop("workDir") + "file_contexts.bin")
+                addArguments("-o " + File(Helper.prop("workDir"), "file_contexts.bin").path)
                 addArgument("aosp/plugged/res/file_contexts.concat")
             }.also { log.warn(it.toString()) }, env)
         }
diff --git a/bbootimg/src/main/kotlin/rom/sparse/SparseImgParser.kt b/bbootimg/src/main/kotlin/rom/sparse/SparseImgParser.kt
index 36b5dee..0848e7c 100644
--- a/bbootimg/src/main/kotlin/rom/sparse/SparseImgParser.kt
+++ b/bbootimg/src/main/kotlin/rom/sparse/SparseImgParser.kt
@@ -59,12 +59,7 @@ class SparseImgParser : IPackable {
 
     override fun pack(fileName: String) {
         //TODO("not implemented: refer to https://github.com/cfig/Android_boot_image_editor/issues/133")
-        val cfgFile = outDir + fileName.removeSuffix(".img") + ".json"
-        val readBackSi = ObjectMapper().readValue(File(cfgFile), SparseImage::class.java)
-        readBackSi
-            .pack()
-            .updateVbmeta()
-            .unwrap()
+        packInternal(Helper.prop("workDir")!!, fileName)
     }
 
     fun packInternal(workspace: String, outFileName: String) {
@@ -83,6 +78,11 @@ class SparseImgParser : IPackable {
         val iniRole = Common.loadProperties(File(workspace, "workspace.ini").canonicalPath).getProperty("role")
         val cfgFile = File(workspace, iniRole.removeSuffix(".img") + ".json").canonicalPath
         log.info("Loading config from $cfgFile")
+        val readBackSi = ObjectMapper().readValue(File(cfgFile), SparseImage::class.java)
+        readBackSi
+            .pack()
+            .updateVbmeta()
+            .unwrap()
     }
 
     // invoked solely by reflection
diff --git a/src/integrationTest/resources_2 b/src/integrationTest/resources_2
index 9b783be..012bda6 160000
--- a/src/integrationTest/resources_2
+++ b/src/integrationTest/resources_2
@@ -1 +1 @@
-Subproject commit 9b783be45a23379d024157a6740fb06ba535e4d4
+Subproject commit 012bda615f1c02f16064c30b828f2307f08a6730
diff --git a/src/integrationTest/resources_3 b/src/integrationTest/resources_3
index 15c3878..b1bff46 160000
--- a/src/integrationTest/resources_3
+++ b/src/integrationTest/resources_3
@@ -1 +1 @@
-Subproject commit 15c3878486abe3f2e42e6e0f4f0d82682546afaf
+Subproject commit b1bff460f66fb916e30a0f7ca0b93bc922412b53