public static void resetPowerloom() {
    { Object old$Module$000 = Stella.$MODULE$.get();
      Object old$Context$000 = Stella.$CONTEXT$.get();

      try {
        Native.setSpecial(Stella.$MODULE$, Stella.$STELLA_MODULE$);
        Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
        { List modules = List.list(Cons.cons(Stella.getStellaModule("PLI", true), Cons.cons(Logic.$PL_ANONYMOUS_MODULE$, Cons.cons(Logic.$PL_KERNEL_MODULE$, Cons.cons(Logic.$LOGIC_MODULE$, Stella.NIL)))));

          { Module mod = null;
            Cons iter000 = modules.theConsList;

            for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
              mod = ((Module)(iter000.value));
              KeyValueList.setDynamicSlotValue(mod.dynamicSlots, Logic.SYM_STELLA_CLEARABLEp, Stella.TRUE_WRAPPER, Stella.FALSE_WRAPPER);
              KeyValueList.setDynamicSlotValue(mod.dynamicSlots, Logic.SYM_STELLA_PROTECT_SURROGATESp, Stella.FALSE_WRAPPER, Stella.FALSE_WRAPPER);
              { Context sub = null;
                AllPurposeIterator iter001 = Context.allSubcontexts(mod, Logic.KWD_PREORDER);

                while (iter001.nextP()) {
                  sub = ((Context)(iter001.value));
                  if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(sub), Logic.SGT_STELLA_MODULE)) {
                    { Module sub000 = ((Module)(sub));

                      KeyValueList.setDynamicSlotValue(sub000.dynamicSlots, Logic.SYM_STELLA_CLEARABLEp, Stella.TRUE_WRAPPER, Stella.FALSE_WRAPPER);
                      KeyValueList.setDynamicSlotValue(sub000.dynamicSlots, Logic.SYM_STELLA_PROTECT_SURROGATESp, Stella.FALSE_WRAPPER, Stella.FALSE_WRAPPER);
                    }
                  }
                  else {
                  }
                }
              }
            }
          }
          { Module mod = null;
            Cons iter002 = modules.theConsList;

            for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) {
              mod = ((Module)(iter002.value));
              Context.clearContext(mod);
            }
          }
          HookList.dropHook(Stella.$DEFINE_MODULE_HOOKS$, Logic.SYM_LOGIC_INTRODUCE_MODULE);
          HookList.dropHook(Stella.$CLEAR_MODULE_HOOKS$, Logic.SYM_LOGIC_CLEAR_LOGIC_MODULE_HOOK);
          HookList.dropHook(Stella.$DESTROY_CONTEXT_HOOKS$, Logic.SYM_LOGIC_DESTROY_LOGIC_CONTEXT_HOOK);
          HookList.dropHook(Stella.$REDEFINE_RELATION_HOOKS$, Logic.SYM_LOGIC_TRANSFER_LOGIC_INFORMATION_FROM_RELATION_HOOK);
          { Module mod = null;
            Cons iter003 = modules.theConsList;

            for (;!(iter003 == Stella.NIL); iter003 = iter003.rest) {
              mod = ((Module)(iter003.value));
              Module.destroyModule(mod);
            }
          }
          Logic.$PL_KERNEL_MODULE$ = null;
          Logic.$LOGIC_MODULE$ = null;
          Stella.clearAllMemoizationTables();
          StartupLogicSystem.startupLogicSystem();
        }

      } finally {
        Stella.$CONTEXT$.set(old$Context$000);
        Stella.$MODULE$.set(old$Module$000);
      }
    }
    Stella.getStellaModule("PL-USER", true).changeModule();
  }