diff --git a/VersionASM b/VersionASM
index f442b3aa88034045a4a0762669338888f90f9c5f..14b10573d4ff9eb7377a356de8d737485d1cdf70 100644
--- a/VersionASM
+++ b/VersionASM
@@ -11,14 +11,14 @@
                         GBLS    Module_HelpVersion
                         GBLS    Module_ComponentName
                         GBLS    Module_ComponentPath
-Module_MajorVersion     SETS    "5.21"
-Module_Version          SETA    521
+Module_MajorVersion     SETS    "5.22"
+Module_Version          SETA    522
 Module_MinorVersion     SETS    ""
-Module_Date             SETS    "08 Nov 2000"
-Module_ApplicationDate2 SETS    "08-Nov-00"
-Module_ApplicationDate4 SETS    "08-Nov-2000"
+Module_Date             SETS    "20 Nov 2000"
+Module_ApplicationDate2 SETS    "20-Nov-00"
+Module_ApplicationDate4 SETS    "20-Nov-2000"
 Module_ComponentName    SETS    "RISC_OSLib"
 Module_ComponentPath    SETS    "RiscOS/Sources/Lib/RISC_OSLib"
-Module_FullVersion      SETS    "5.21"
-Module_HelpVersion      SETS    "5.21 (08 Nov 2000)"
+Module_FullVersion      SETS    "5.22"
+Module_HelpVersion      SETS    "5.22 (20 Nov 2000)"
                         END
diff --git a/VersionNum b/VersionNum
index 94379107b1728718c31478462614a8b8380ef61c..3ae29c1bbdd9f67c8968cd1ece048bf5416d0617 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,22 +1,22 @@
-/* (5.21)
+/* (5.22)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  *
  */
-#define Module_MajorVersion_CMHG        5.21
+#define Module_MajorVersion_CMHG        5.22
 #define Module_MinorVersion_CMHG        
-#define Module_Date_CMHG                08 Nov 2000
+#define Module_Date_CMHG                20 Nov 2000
 
-#define Module_MajorVersion             "5.21"
-#define Module_Version                  521
+#define Module_MajorVersion             "5.22"
+#define Module_Version                  522
 #define Module_MinorVersion             ""
-#define Module_Date                     "08 Nov 2000"
+#define Module_Date                     "20 Nov 2000"
 
-#define Module_ApplicationDate2         "08-Nov-00"
-#define Module_ApplicationDate4         "08-Nov-2000"
+#define Module_ApplicationDate2         "20-Nov-00"
+#define Module_ApplicationDate4         "20-Nov-2000"
 
 #define Module_ComponentName            "RISC_OSLib"
 #define Module_ComponentPath            "RiscOS/Sources/Lib/RISC_OSLib"
 
-#define Module_FullVersion              "5.21"
-#define Module_HelpVersion              "5.21 (08 Nov 2000)"
+#define Module_FullVersion              "5.22"
+#define Module_HelpVersion              "5.22 (20 Nov 2000)"
diff --git a/kernel/s/k_body b/kernel/s/k_body
index b07e874718c936d221b260af8f7709428cf532e2..8e2f5c1fdec50b6c2c80b00f8b6cee0c946c346e 100644
--- a/kernel/s/k_body
+++ b/kernel/s/k_body
@@ -915,15 +915,25 @@ Aborted Keep
         STR     r1, [r6, #pc*4]         ; PC as user R14
         STR     r2, [r6, #r0*4]
         STREQ   r3, [r6, #r12*4]
-        BEQ     AbortFindHandler
+        BEQ     AbortFlattenStacks
         LDR     r4, [r12, #O_svcStack]
         SUB     r1, r4, sp
         CMP     r1, #3 * 4
-        BCC     AbortFindHandler
+        BCC     AbortFlattenStacks
         LDMEA   r4, {r1, r2, r3}
         ADD     r4, r6, #10 * 4
         STMIA   r4, {r1, r2, r3}
 
+; should really fall through to error handler and let the OS clean up,
+; but this is a lot better than it was!
+AbortFlattenStacks
+        MRS     r4, CPSR                ; MRS and MSR here will be NOPs on
+        ORR     r1, r4, #PSR32UNDMode   ; ARM2/3, so we'll end up setting
+        MSR     CPSR_c, r1              ; R13_svc twice; just make sure
+        LDR     sp, [r12, #O_undStack]  ; we set the real value last.
+        MSR     CPSR_c, r4
+        LDR     sp, [r12, #O_svcStack]
+
 AbortFindHandler Keep
 ; We can only call an abort handler if we had a stack at the
 ; time of the abort.  If not, we have to say 'uncaught trap'.
@@ -1173,6 +1183,10 @@ FindAndCallHandlers Keep
 FCH_NextFrame
         [ {CONFIG}=26
         BIC     r1, r1, #PSRBits
+        |
+        MRS     v4, CPSR
+        TST     v4, #2_11100
+        BICEQ   r1, r1, #PSRBits
         ]
         LDMIB   v6, {v4, v5}
 FCH_NextLanguage Keep