if(Canrestore == 0)
                      {
                          if(Otherwin)
-                             fault = new FillNOther(Wstate<5:3>);
+                             fault = new FillNOther(4*Wstate<5:3>);
                          else
-                             fault = new FillNNormal(Wstate<2:0>);
+                             fault = new FillNNormal(4*Wstate<2:0>);
                      }
 +                    //Check for alignment faults
 +                    else if(target & 0x3)
 +                        fault = new MemAddressNotAligned;
                      else
                      {
 -                        //CWP should be set directly so that it always happens
 -                        //Also, this will allow writing to the new window and
 -                        //reading from the old one
 +                        NNPC = target;
                          Cwp = (Cwp - 1 + NWindows) % NWindows;
                          Cansave = Cansave + 1;
                          Canrestore = Canrestore - 1;
                  if(Cansave == 0)
                  {
                      if(Otherwin)
-                         fault = new SpillNOther(Wstate<5:3>);
+                         fault = new SpillNOther(4*Wstate<5:3>);
                      else
-                         fault = new SpillNNormal(Wstate<2:0>);
+                         fault = new SpillNNormal(4*Wstate<2:0>);
 -                    //Cwp = (Cwp + 2) % NWindows;
                  }
                  else if(Cleanwin - Canrestore == 0)
                  {
 
                  flag_code = "flags[IsLastMicroOp] = true;"
                  pcedCode = matcher.sub("RdHigh", code)
              else:
-                 flag_code = "flags[IsDelayedCommit] = true;"
+                 flag_code = "flags[IsDelayedCommit] = true; flags[IsFirstMicroOp] = true;"
                  pcedCode = matcher.sub("RdLow", code)
 -            iop = InstObjParams(name, Name, 'TwinMem', pcedCode,
 -                    opt_flags, {"ea_code": addrCalcReg,
 +            iop = InstObjParams(name, Name, 'TwinMem',
 +                    {"code": pcedCode, "ea_code": addrCalcReg,
                      "fault_check": faultCode, "micro_pc": microPc,
 -                    "set_flags": flag_code})
 -            iop_imm = InstObjParams(name, Name + 'Imm', 'TwinMemImm', pcedCode,
 -                    opt_flags, {"ea_code": addrCalcImm,
 +                    "set_flags": flag_code}, opt_flags)
 +            iop_imm = InstObjParams(name, Name + 'Imm', 'TwinMemImm',
 +                    {"code": pcedCode, "ea_code": addrCalcImm,
                      "fault_check": faultCode, "micro_pc": microPc,
 -                    "set_flags": flag_code})
 +                    "set_flags": flag_code}, opt_flags)
              decoder_output += BlockMemMicroConstructor.subst(iop)
              decoder_output += BlockMemMicroConstructor.subst(iop_imm)
              exec_output += doDualSplitExecute(
 
  
  //For conversions not involving the guest system, we can define the functions
  //conditionally based on the BYTE_ORDER macro and outside of the namespaces
- #if defined(_BIG_ENDIAN) || BYTE_ORDER == BIG_ENDIAN
+ #if defined(_BIG_ENDIAN) || !defined(_LITTLE_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
 +const ByteOrder HostByteOrder = BigEndianByteOrder;
  template <typename T> static inline T htole(T value) {return swap_byte(value);}
  template <typename T> static inline T letoh(T value) {return swap_byte(value);}
  template <typename T> static inline T htobe(T value) {return value;}