Here is a patch for both:
--- a/src/Flash.asm
+++ b/src/Flash.asm
@@ -563,13 +563,13 @@ EM_survey:
moveq #1,d1 ; Calculate
and.w d0,d1 ; d1 = 1 if odd, 0 if even
add.w d1,d0 ; Even upper address
- add.l d0,a0 ; Next entry
cmp.w #ARC_ST_DELETED,(a0)
bne.s \NoDel
add.l d0,d4 ; Add it to FreeAfterGC
bra.s \NextNoDel
\NoDel: add.l d0,d3 ; Add it to InUse
-\NextNoDel: cmp.l a1,a0 ; In the same sector ?
+\NextNoDel: add.l d0,a0 ; Next entry
+ cmp.l a1,a0 ; In the same sector ?
bcs.s \SectorLoop ; Next Entry in Sector
\NextSector ; Next Sector
move.l a1,a0 ; New Start
@@ -923,7 +923,8 @@ EM_GC:
beq.s \Failed ; Failed to erase it
; Pop all handles
\RestoreLoop move.w (a7)+,d7 ; Handle
+ move.l a3,a4 ; Save end of sector
jsr EM_findEmptySlot ; It could not failed since we have empty a sector
lea -ARC_ENTRY.HeaderSize(a0),a3 ; Dest
move.w d7,a0
@@ -937,7 +938,8 @@ EM_GC:
lsl.w #2,d0
move.l a1,0(a0,d0.w) ; Save new addr of the handle
move.w d7,d0
+ move.l a4,a3 ; Restore end of sector
bra.s \RestoreLoop
\NextSector move.l a3,a2 ; New Start
adda.l #$10000,a3 ; New End