[Avida-cvs] [Avida2-svn] r402 - in development: . Avida.xcodeproj source/analyze source/cpu source/event source/main source/tools source/viewer

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Thu Nov 17 13:18:16 PST 2005


Author: brysonda
Date: 2005-11-17 16:14:48 -0500 (Thu, 17 Nov 2005)
New Revision: 402

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/analyze/cAnalyze.cc
   development/source/analyze/cAnalyzeGenotype.cc
   development/source/cpu/cCPUStack.cc
   development/source/cpu/cCPUStack.h
   development/source/cpu/cHardware4Stack.cc
   development/source/cpu/cHardware4Stack.h
   development/source/cpu/cHardwareBase.cc
   development/source/cpu/cHardwareBase.h
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
   development/source/cpu/cHardwareManager.cc
   development/source/cpu/cHardwareSMT.cc
   development/source/cpu/cHardwareSMT.h
   development/source/cpu/cHeadMultiMem.h
   development/source/cpu/sCPUStats.h
   development/source/cpu/tInstLib.h
   development/source/event/cEventManager.cc
   development/source/main/cOrganism.cc
   development/source/main/cPopulation.cc
   development/source/main/cReactionProcess.cc
   development/source/main/cReactionProcess.h
   development/source/main/cTaskLib.cc
   development/source/tools/cChangeList.cc
   development/source/viewer/cSymbolUtil.cc
   development/source/viewer/cView.cc
   development/source/viewer/cZoomScreen.cc
   development/status.xml
Log:
Standardize most of the HardwareCPU interface, privatize much of the implementation functions.  Remove some casting in areas that can now make use of the standardized interface.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2005-11-16 00:50:47 UTC (rev 401)
+++ development/Avida.xcodeproj/project.pbxproj	2005-11-17 21:14:48 UTC (rev 402)
@@ -772,7 +772,7 @@
 		DCC315CF076253A5008F7A48 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
 		DCC315D0076253A5008F7A48 /* task_event_gen.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.cc; sourceTree = "<group>"; };
 		DCC315D1076253A5008F7A48 /* task_event_gen.old.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.old.cc; sourceTree = "<group>"; };
-		DCC3164D07626CF3008F7A48 /* primitive */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = primitive; sourceTree = BUILT_PRODUCTS_DIR; };
+		DCC3164D07626CF3008F7A48 /* primitive */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = primitive; sourceTree = BUILT_PRODUCTS_DIR; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -1946,6 +1946,8 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
+				GCC_WARN_PEDANTIC = NO;
 			};
 			name = Development;
 		};

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/analyze/cAnalyze.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -2513,7 +2513,7 @@
   cAnalyzeGenotype * genotype = NULL;
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   
-  while (((genotype = batch_it.Next()) != NULL) && (community.size() < max_genotypes)) {
+  while (((genotype = batch_it.Next()) != NULL) && (community.size() < static_cast<unsigned int>(max_genotypes))) {
     community.push_back(genotype);
   }
   
@@ -2711,7 +2711,7 @@
                                                     given_genotypes[0]->GetID()))->second;
       int min_depth_dist = genotype->GetDepth() + given_genotypes[0]->GetDepth() - 2 * tmrca->GetDepth();
       
-      for (int i = 1; i < given_genotypes.size() ; ++ i) {
+      for (unsigned int i = 1; i < given_genotypes.size() ; ++ i) {
         cAnalyzeGenotype * given_genotype = given_genotypes[i];
         cAnalyzeGenotype * tmrca = mrca.find(gen_pair(genotype->GetID(),
                                                       given_genotype->GetID()))->second;
@@ -2984,7 +2984,7 @@
     ///////////////////////////////////////////////////////////////////////
     // Choose the first n most abundant genotypes and put them in community
     
-    while (((genotype = batch_it.Next()) != NULL) && (community.size() < max_genotypes)) {
+    while (((genotype = batch_it.Next()) != NULL) && (community.size() < static_cast<unsigned int>(max_genotypes))) {
       community.push_back(genotype);
     }
   } else if (max_genotypes == 0) {
@@ -3153,7 +3153,7 @@
     tMatrix<double> this_prob = point_mut.find(genotype->GetID())->second;
     
     // For any given genotype, calculate the new information in genotype
-    for (int j = 0; j < given_genotypes.size(); ++ j) {
+    for (unsigned int j = 0; j < given_genotypes.size(); ++ j) {
       
       tMatrix<double> given_prob = point_mut.find(given_genotypes[j]->GetID())->second;
       double new_info = 0.0;

Modified: development/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- development/source/analyze/cAnalyzeGenotype.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/analyze/cAnalyzeGenotype.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -180,7 +180,7 @@
   
   // If the base fitness is 0, the organism is dead and has no complexity.
   if (base_fitness == 0.0) {
-    knockout_stats->neut_count == length;
+    knockout_stats->neut_count = length;
     return;
   }
   

Modified: development/source/cpu/cCPUStack.cc
===================================================================
--- development/source/cpu/cCPUStack.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cCPUStack.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -1,9 +1,12 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2001 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
+/*
+ *  cCPUStack.cc
+ *  Avida
+ *
+ *  Created by David on 11/17/05.
+ *  Copyright 2005 Michigan State University. All rights reserved.
+ *  Copyright 1999-2001 California Institute of Technology.
+ *
+ */
 
 #include "cCPUStack.h"
 
@@ -13,11 +16,6 @@
 using namespace std;
 
 
-cCPUStack::cCPUStack()
-{
-  Clear();
-}
-
 cCPUStack::cCPUStack(const cCPUStack & in_stack)
 {
   for (int i = 0; i < nHardware::STACK_SIZE; i++) {
@@ -26,10 +24,6 @@
   stack_pointer = in_stack.stack_pointer;
 }
 
-cCPUStack::~cCPUStack()
-{
-}
-
 void cCPUStack::operator=(const cCPUStack & in_stack)
 {
   for (int i = 0; i < nHardware::STACK_SIZE; i++) {

Modified: development/source/cpu/cCPUStack.h
===================================================================
--- development/source/cpu/cCPUStack.h	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cCPUStack.h	2005-11-17 21:14:48 UTC (rev 402)
@@ -1,12 +1,15 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
+/*
+ *  cCPUStack.h
+ *  Avida
+ *
+ *  Created by David on 11/17/05.
+ *  Copyright 2005 Michigan State University. All rights reserved.
+ *  Copyright 1999-2001 California Institute of Technology.
+ *
+ */
 
-#ifndef CPU_STACK_HH
-#define CPU_STACK_HH
+#ifndef cCPUStack_h
+#define cCPUStack_h
 
 #include <iostream>
 
@@ -14,25 +17,21 @@
 #include "nHardware.h"
 #endif
 
-/**
- * A CPU stack, used by various hardware components.
- *
- * @see cCPUThread, cHeadCPU, cHardware
- **/
-
 class cCPUStack {
 private:
   int stack[nHardware::STACK_SIZE];
   unsigned char stack_pointer;
 public:
-  cCPUStack();
+  cCPUStack() { Clear(); }
   cCPUStack(const cCPUStack & in_stack);
-  ~cCPUStack();
+  ~cCPUStack() { ; }
 
   void operator=(const cCPUStack & in_stack);
 
   inline void Push(int value);
   inline int Pop();
+  inline int& Peek() { return stack[stack_pointer]; }
+  inline const int Peek() const { return stack[stack_pointer]; }
   inline int Get(int depth=0) const;
   inline void Clear();
   inline int Top();

Modified: development/source/cpu/cHardware4Stack.cc
===================================================================
--- development/source/cpu/cHardware4Stack.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHardware4Stack.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -1,12 +1,13 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
+/*
+ *  cHardware4Stack.cc
+ *  Avida
+ *
+ *  Created by David on 11/17/05.
+ *  Copyright 2005 Michigan State University. All rights reserved.
+ *  Copyright 1999-2003 California Institute of Technology.
+ *
+ */
 
-
-
 #include "cHardware4Stack.h"
 
 #include "cCPUTestInfo.h"
@@ -30,13 +31,8 @@
 using namespace std;
 
 
-
-
-///////////////
-//  cInstLib4Stack
-///////////////
-
-class cInstLib4Stack : public cInstLibBase {
+class cInstLib4Stack : public cInstLibBase
+{
   const size_t m_nopmods_array_size;
   const size_t m_function_array_size;
   cString *m_nopmod_names;
@@ -46,14 +42,14 @@
   static const cInstruction inst_error;
   static const cInstruction inst_default;
 public:
-  cInstLib4Stack(
-    size_t nopmod_array_size,
-    size_t function_array_size,
-    cString *nopmod_names,
-    cString *function_names,
-    const int *nopmods,
-    cHardware4Stack::tHardware4StackMethod *functions
-  ):m_nopmods_array_size(nopmod_array_size),
+    cInstLib4Stack(
+                   size_t nopmod_array_size,
+                   size_t function_array_size,
+                   cString *nopmod_names,
+                   cString *function_names,
+                   const int *nopmods,
+                   cHardware4Stack::tHardware4StackMethod *functions
+                   ):m_nopmods_array_size(nopmod_array_size),
     m_function_array_size(function_array_size),
     m_nopmod_names(nopmod_names),
     m_function_names(function_names),
@@ -88,16 +84,15 @@
   const cInstruction & GetInstError(){ return inst_error; }
 };
 
-///////////////
-//  cHardware4Stack
-///////////////
-
 const cInstruction cInstLib4Stack::inst_error(255);
 const cInstruction cInstLib4Stack::inst_default(0);
-cInstLibBase *cHardware4Stack::GetInstLib(){ return s_inst_slib; }
 
-cInstLib4Stack *cHardware4Stack::s_inst_slib = cHardware4Stack::initInstLib();
-cInstLib4Stack *cHardware4Stack::initInstLib(void){
+cInstLib4Stack* cHardware4Stack::s_inst_slib = cHardware4Stack::initInstLib();
+
+cInstLibBase* cHardware4Stack::GetInstLib() { return s_inst_slib; }
+
+cInstLib4Stack* cHardware4Stack::initInstLib(void)
+{
   struct cNOPEntry4Stack {
     cNOPEntry4Stack(const cString &name, int nop_mod):name(name), nop_mod(nop_mod){}
     cString name;
@@ -111,7 +106,7 @@
     cNOPEntry4Stack("Nop-E", nHardware4Stack::STACK_EX),
     cNOPEntry4Stack("Nop-F", nHardware4Stack::STACK_FX)
   };
-
+  
   struct cInstEntry4Stack {
     cInstEntry4Stack(const cString &name, tHardware4StackMethod function):name(name), function(function){}
     cString name;
@@ -199,16 +194,16 @@
     //37
     cInstEntry4Stack("Inject", &cHardware4Stack::Inst_Inject)
   };
-
+  
   const int n_size = sizeof(s_n_array)/sizeof(cNOPEntry4Stack);
-
+  
   static cString n_names[n_size];
   static int nop_mods[n_size];
   for (int i = 0; i < n_size; i++){
     n_names[i] = s_n_array[i].name;
     nop_mods[i] = s_n_array[i].nop_mod;
   }
-
+  
   const int f_size = sizeof(s_f_array)/sizeof(cInstEntry4Stack);
   static cString f_names[f_size];
   static tHardware4StackMethod functions[f_size];
@@ -216,33 +211,33 @@
     f_names[i] = s_f_array[i].name;
     functions[i] = s_f_array[i].function;
   }
-
+  
   cInstLib4Stack *inst_lib = new cInstLib4Stack(
-    n_size,
-    f_size,
-    n_names,
-    f_names,
-    nop_mods,
-    functions
-  );
-
+                                                n_size,
+                                                f_size,
+                                                n_names,
+                                                f_names,
+                                                nop_mods,
+                                                functions
+                                                );
+  
   return inst_lib;
 }
 
-cHardware4Stack::cHardware4Stack(cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set)
-  : cHardwareBase(world, in_organism, in_inst_set)
-  , memory_array(nHardware4Stack::NUM_MEMORY_SPACES)
+cHardware4Stack::cHardware4Stack(cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
+: cHardwareBase(world, in_organism, in_m_inst_set)
+, memory_array(nHardware4Stack::NUM_MEMORY_SPACES)
 {
   /* FIXME:  reorganize storage of m_functions.  -- kgn */
   m_functions = s_inst_slib->GetFunctions();
   /**/
   inst_remainder = 0;
- 
+  
   for(int x=1; x <= m_world->GetConfig().MAX_CPU_THREADS.Get(); x++)
-    {
-      slice_array[x] = (x-1) * m_world->GetConfig().THREAD_SLICING_METHOD.Get() + 1;
-    }
-
+  {
+    slice_array[x] = (x-1) * m_world->GetConfig().THREAD_SLICING_METHOD.Get() + 1;
+  }
+  
   memory_array[0] = in_organism->GetGenome();  // Initialize memory...
   memory_array[0].Resize(GetMemory(0).GetSize()+1);
   memory_array[0][memory_array[0].GetSize()-1] = cInstruction();
@@ -251,13 +246,12 @@
 
 
 cHardware4Stack::cHardware4Stack(const cHardware4Stack &hardware_4stack)
-: cHardwareBase(hardware_4stack.m_world, hardware_4stack.organism, hardware_4stack.inst_set)
+: cHardwareBase(hardware_4stack.m_world, hardware_4stack.organism, hardware_4stack.m_inst_set)
 , m_functions(hardware_4stack.m_functions)
 , memory_array(hardware_4stack.memory_array)
 , threads(hardware_4stack.threads)
 , thread_id_chart(hardware_4stack.thread_id_chart)
 , cur_thread(hardware_4stack.cur_thread)
-, mal_active(hardware_4stack.mal_active)
 , inst_cost(hardware_4stack.inst_cost)
 #ifdef INSTRUCTION_COSTS
 , inst_ft_cost(hardware_4stack.inst_ft_cost)
@@ -267,7 +261,7 @@
   for(int i = 0; i < nHardware4Stack::NUM_GLOBAL_STACKS; i++){
     global_stacks[i] = hardware_4stack.global_stacks[i];
   }
-  for(int i = 0; i < sizeof(slice_array)/sizeof(float); i++){
+  for(unsigned int i = 0; i < sizeof(slice_array)/sizeof(float); i++){
     slice_array[i] = hardware_4stack.slice_array[i];
   }
 }
@@ -277,42 +271,37 @@
 {
   //global_stack.Clear();
   //thread_time_used = 0;
-
+  
   // Setup the memory...
   for (int i = 1; i < nHardware4Stack::NUM_MEMORY_SPACES; i++) {
-      memory_array[i].Resize(1);
-      //GetMemory(i).Replace(0, 1, cGenome(ConvertToInstruction(i)));
-      GetMemory(i)=cGenome(ConvertToInstruction(i)); 
+    memory_array[i].Resize(1);
+    //GetMemory(i).Replace(0, 1, cGenome(ConvertToInstruction(i)));
+    GetMemory(i)=cGenome(ConvertToInstruction(i)); 
   }
-
+  
   // We want to reset to have a single thread.
   threads.Resize(1);
-
+  
   // Reset that single thread.
   threads[0].Reset(this, 0);
   thread_id_chart = 1; // Mark only the first thread as taken...
   cur_thread = 0;
-
-  mal_active = false;
-
+  
   // Reset all stacks (local and global)
-  for(int i=0; i<nHardware4Stack::NUM_STACKS; i++)
-    {
-      Stack(i).Clear();
-    }
-
+  for(int i = 0; i < nHardware4Stack::NUM_STACKS; i++) Stack(i).Clear();
+  
 #ifdef INSTRUCTION_COSTS
   // instruction cost arrays
-  const int num_inst_cost = GetNumInst();
+  const int num_inst_cost = m_inst_set->GetSize();
   inst_cost.Resize(num_inst_cost);
   inst_ft_cost.Resize(num_inst_cost);
-
+  
   for (int i = 0; i < num_inst_cost; i++) {
-    inst_cost[i] = GetInstSet().GetCost(cInstruction(i));
-    inst_ft_cost[i] = GetInstSet().GetFTCost(cInstruction(i));
+    inst_cost[i] = m_inst_set->GetCost(cInstruction(i));
+    inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
   }
 #endif
-
+  
 }
 
 // This function processes the very next command in the genome, and is made
@@ -322,10 +311,10 @@
 {
   // Mark this organism as running...
   organism->SetRunning(true);
-
+  
   cPhenotype & phenotype = organism->GetPhenotype();
   phenotype.IncTimeUsed();
-
+  
   const int num_inst_exec = int(slice_array[GetNumThreads()]+ inst_remainder);
   inst_remainder = slice_array[GetNumThreads()] + inst_remainder - num_inst_exec;
   
@@ -334,7 +323,7 @@
     NextThread();
     AdvanceIP() = true;
     IP().Adjust();
-
+    
 #ifdef BREAKPOINTS
     if (IP().FlagBreakpoint() == true) {
       organism->DoBreakpoint();
@@ -345,35 +334,35 @@
     if (m_tracer != NULL) {
       if (cHardwareTracer_4Stack * tracer
           = dynamic_cast<cHardwareTracer_4Stack *>(m_tracer)
-      ){
+          ){
         tracer->TraceHardware_4Stack(*this);
       }
     }
     
     // Find the instruction to be executed
     const cInstruction & cur_inst = IP().GetInst();
-
+    
     // Test if costs have been paid and it is okay to execute this now...
     const bool exec = SingleProcess_PayCosts(cur_inst);
-
+    
     // Now execute the instruction...
     if (exec == true) {
       SingleProcess_ExecuteInst(cur_inst);
-
+      
       // Some instruction (such as jump) may turn advance_ip off.  Ususally
       // we now want to move to the next instruction in the memory.
       if (AdvanceIP() == true) IP().Advance();
     } // if exec
     
   } // Previous was executed once for each thread...
-
+  
   // Kill creatures who have reached their max num of instructions executed
   const int max_executed = organism->GetMaxExecuted();
   if ((max_executed > 0 && phenotype.GetTimeUsed() >= max_executed)
       || phenotype.GetToDie()) {
     organism->Die();
   }
-
+  
   organism->SetRunning(false);
 }
 
@@ -384,26 +373,26 @@
 {
 #ifdef INSTRUCTION_COSTS
   assert(cur_inst.GetOp() < inst_cost.GetSize());
-
+  
   // If first time cost hasn't been paid off...
   if ( inst_ft_cost[cur_inst.GetOp()] > 0 ) {
     inst_ft_cost[cur_inst.GetOp()]--;       // dec cost
     return false;
   }
-    
+  
   // Next, look at the per use cost
-  if ( GetInstSet().GetCost(cur_inst) > 0 ) {
+  if ( m_inst_set->GetCost(cur_inst) > 0 ) {
     if ( inst_cost[cur_inst.GetOp()] > 1 ){  // if isn't paid off (>1)
       inst_cost[cur_inst.GetOp()]--;         // dec cost
       return false;
     } else {                                 // else, reset cost array
-      inst_cost[cur_inst.GetOp()] = GetInstSet().GetCost(cur_inst);
+      inst_cost[cur_inst.GetOp()] = m_inst_set->GetCost(cur_inst);
     }
   }
-    
+  
   // Prob of exec
-  if ( GetInstSet().GetProbFail(cur_inst) > 0.0 ){
-    return !( m_world->GetRandom().P(GetInstSet().GetProbFail(cur_inst)) );
+  if ( m_inst_set->GetProbFail(cur_inst) > 0.0 ){
+    return !( m_world->GetRandom().P(m_inst_set->GetProbFail(cur_inst)) );
   }
 #endif
   return true;
@@ -418,16 +407,16 @@
   
 #ifdef EXECUTION_ERRORS
   // If there is an execution error, execute a random instruction.
-  if (organism->TestExeErr()) actual_inst = GetInstSet().GetRandomInst();
+  if (organism->TestExeErr()) actual_inst = m_inst_set->GetRandomInst();
 #endif /* EXECUTION_ERRORS */
-
+  
   // Get a pointer to the corrisponding method...
-  int inst_idx = GetInstSet().GetLibFunctionIndex(actual_inst);
+  int inst_idx = m_inst_set->GetLibFunctionIndex(actual_inst);
   
   // Mark the instruction as executed
   IP().FlagExecuted() = true;
 	
-
+  
 #ifdef INSTRUCTION_COUNT
   // instruction execution count incremeneted
   organism->GetPhenotype().IncCurInstCount(actual_inst.GetOp());
@@ -442,7 +431,7 @@
     organism->GetPhenotype().DecCurInstCount(actual_inst.GetOp());
   }
 #endif	
-
+  
   return exec_success;
 }
 
@@ -452,74 +441,67 @@
   // Mark this organism as running...
   bool prev_run_state = organism->GetIsRunning();
   organism->SetRunning(true);
-
+  
   // @CAO FIX PRINTING TO INDICATE THIS IS A BONUS
   // Print the status of this CPU at each step...
   if (m_tracer != NULL) {
     if (cHardwareTracer_4Stack * tracer
         = dynamic_cast<cHardwareTracer_4Stack *>(m_tracer)
-    ){
+        ){
       tracer->TraceHardware_4StackBonus(*this);
     }
   }
-    
+  
   SingleProcess_ExecuteInst(inst);
-
+  
   organism->SetRunning(prev_run_state);
 }
 
-
-void cHardware4Stack::LoadGenome(const cGenome & new_genome)
-{
-  GetMemory(0) = new_genome;
-}
-
-
 bool cHardware4Stack::OK()
 {
   bool result = true;
-
+  
   for(int i = 0 ; i < nHardware4Stack::NUM_MEMORY_SPACES; i++) {
     if (!memory_array[i].OK()) result = false;
   }
-
+  
   for (int i = 0; i < GetNumThreads(); i++) {
     for(int j=0; j<nHardware4Stack::NUM_LOCAL_STACKS; j++)
-    if (threads[i].local_stacks[j].OK() == false) result = false;
+      if (threads[i].local_stacks[j].OK() == false) result = false;
     if (threads[i].next_label.OK() == false) result = false;
   }
-
+  
   return result;
 }
 
 void cHardware4Stack::PrintStatus(ostream& fp)
 {
   fp << organism->GetPhenotype().GetTimeUsed() << " "
-     << "IP:(" << IP().GetMemSpace() << ", " << IP().GetPosition() << ")    "
-
-     << "AX:" << Stack(nHardware4Stack::STACK_AX).Top() << " "
-     << setbase(16) << "[0x" << Stack(nHardware4Stack::STACK_AX).Top() << "]  " << setbase(10)
-
-     << "BX:" << Stack(nHardware4Stack::STACK_BX).Top() << " "
-     << setbase(16) << "[0x" << Stack(nHardware4Stack::STACK_BX).Top() << "]  " << setbase(10)
-
-     << "CX:" << Stack(nHardware4Stack::STACK_CX).Top() << " "
-     << setbase(16) << "[0x" << Stack(nHardware4Stack::STACK_CX).Top() << "]  " << setbase(10)
-
-     << "DX:" << Stack(nHardware4Stack::STACK_DX).Top() << " "
-     << setbase(16) << "[0x" << Stack(nHardware4Stack::STACK_DX).Top() << "]  " << setbase(10)
-
-     << endl;
-
+  << "IP:(" << IP().GetMemSpace() << ", " << IP().GetPosition() << ")    "
+  
+  << "AX:" << Stack(nHardware4Stack::STACK_AX).Top() << " "
+  << setbase(16) << "[0x" << Stack(nHardware4Stack::STACK_AX).Top() << "]  " << setbase(10)
+  
+  << "BX:" << Stack(nHardware4Stack::STACK_BX).Top() << " "
+  << setbase(16) << "[0x" << Stack(nHardware4Stack::STACK_BX).Top() << "]  " << setbase(10)
+  
+  << "CX:" << Stack(nHardware4Stack::STACK_CX).Top() << " "
+  << setbase(16) << "[0x" << Stack(nHardware4Stack::STACK_CX).Top() << "]  " << setbase(10)
+  
+  << "DX:" << Stack(nHardware4Stack::STACK_DX).Top() << " "
+  << setbase(16) << "[0x" << Stack(nHardware4Stack::STACK_DX).Top() << "]  " << setbase(10)
+  
+  << endl;
+  
   fp << "  R-Head:(" << GetHead(nHardware::HEAD_READ).GetMemSpace() << ", " 
-     << GetHead(nHardware::HEAD_READ).GetPosition() << ")  " 
-     << "W-Head:(" << GetHead(nHardware::HEAD_WRITE).GetMemSpace()  << ", "
-     << GetHead(nHardware::HEAD_WRITE).GetPosition() << ")  "
-     << "F-Head:(" << GetHead(nHardware::HEAD_FLOW).GetMemSpace()   << ",  "
-     << GetHead(nHardware::HEAD_FLOW).GetPosition() << ")  "
-     << "RL:" << GetReadLabel().AsString() << "   "
-     << endl;
-
+    << GetHead(nHardware::HEAD_READ).GetPosition() << ")  " 
+    << "W-Head:(" << GetHead(nHardware::HEAD_WRITE).GetMemSpace()  << ", "
+    << GetHead(nHardware::HEAD_WRITE).GetPosition() << ")  "
+    << "F-Head:(" << GetHead(nHardware::HEAD_FLOW).GetMemSpace()   << ",  "
+    << GetHead(nHardware::HEAD_FLOW).GetPosition() << ")  "
+    << "RL:" << GetReadLabel().AsString() << "   "
+    << endl;
+  
   fp << "  Mem (" << GetMemory(0).GetSize() << "):"
 		  << "  " << GetMemory(0).AsString()
 		  << endl;
@@ -552,30 +534,30 @@
 cHeadMultiMem cHardware4Stack::FindLabel(int direction)
 {
   cHeadMultiMem & inst_ptr = IP();
-
+  
   // Start up a search head at the position of the instruction pointer.
   cHeadMultiMem search_head(inst_ptr);
   cCodeLabel & search_label = GetLabel();
-
+  
   // Make sure the label is of size  > 0.
-
+  
   if (search_label.GetSize() == 0) {
     return inst_ptr;
   }
-
+  
   // Call special functions depending on if jump is forwards or backwards.
   int found_pos = 0;
   if( direction < 0 ) {
     found_pos = FindLabel_Backward(search_label, inst_ptr.GetMemory(),
-			   inst_ptr.GetPosition() - search_label.GetSize());
+                                   inst_ptr.GetPosition() - search_label.GetSize());
   }
-
+  
   // Jump forward.
   else if (direction > 0) {
     found_pos = FindLabel_Forward(search_label, inst_ptr.GetMemory(),
-			   inst_ptr.GetPosition());
+                                  inst_ptr.GetPosition());
   }
-
+  
   // Jump forward from the very beginning.
   else {
     found_pos = FindLabel_Forward(search_label, inst_ptr.GetMemory(), 0);
@@ -595,80 +577,80 @@
 // to find search label's match inside another label.
 
 int cHardware4Stack::FindLabel_Forward(const cCodeLabel & search_label,
-				 const cGenome & search_genome, int pos)
+                                       const cGenome & search_genome, int pos)
 {
   assert (pos < search_genome.GetSize() && pos >= 0);
-
+  
   int search_start = pos;
   int label_size = search_label.GetSize();
   bool found_label = false;
-
+  
   // Move off the template we are on.
   pos += label_size;
-
+  
   // Search until we find the complement or exit the memory.
   while (pos < search_genome.GetSize()) {
-
+    
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
-
-    if (inst_set->IsNop(search_genome[pos])) {
+    
+    if (m_inst_set->IsNop(search_genome[pos])) {
       // Find the start and end of the label we're in the middle of.
-
+      
       int start_pos = pos;
       int end_pos = pos + 1;
       while (start_pos > search_start &&
-	     inst_set->IsNop( search_genome[start_pos - 1] )) {
-	start_pos--;
+             m_inst_set->IsNop( search_genome[start_pos - 1] )) {
+        start_pos--;
       }
       while (end_pos < search_genome.GetSize() &&
-	     inst_set->IsNop( search_genome[end_pos] )) {
-	end_pos++;
+             m_inst_set->IsNop( search_genome[end_pos] )) {
+        end_pos++;
       }
       int test_size = end_pos - start_pos;
-
+      
       // See if this label has the proper sub-label within it.
       int max_offset = test_size - label_size + 1;
       int offset = start_pos;
       for (offset = start_pos; offset < start_pos + max_offset; offset++) {
-
-	// Test the number of matches for this offset.
-	int matches;
-	for (matches = 0; matches < label_size; matches++) {
-	  if (search_label[matches] !=
-	      inst_set->GetNopMod( search_genome[offset + matches] )) {
-	    break;
-	  }
-	}
-
-	// If we have found it, break out of this loop!
-	if (matches == label_size) {
-	  found_label = true;
-	  break;
-	}
+        
+        // Test the number of matches for this offset.
+        int matches;
+        for (matches = 0; matches < label_size; matches++) {
+          if (search_label[matches] !=
+              m_inst_set->GetNopMod( search_genome[offset + matches] )) {
+            break;
+          }
+        }
+        
+        // If we have found it, break out of this loop!
+        if (matches == label_size) {
+          found_label = true;
+          break;
+        }
       }
-
+      
       // If we've found the complement label, set the position to the end of
       // the label we found it in, and break out.
-
+      
       if (found_label == true) {
-	// pos = end_pos;
-	pos = label_size + offset;
-	break;
+        // pos = end_pos;
+        pos = label_size + offset;
+        break;
       }
-
+      
       // We haven't found it; jump pos to just after the current label being
       // checked.
       pos = end_pos;
     }
-
+    
     // Jump up a block to the next possible point to find a label,
     pos += label_size;
   }
-
+  
   // If the label was not found return a -1.
   if (found_label == false) pos = -1;
-
+  
   return pos;
 }
 
@@ -677,76 +659,76 @@
 // to find search label's match inside another label.
 
 int cHardware4Stack::FindLabel_Backward(const cCodeLabel & search_label,
-				  const cGenome & search_genome, int pos)
+                                        const cGenome & search_genome, int pos)
 {
   assert (pos < search_genome.GetSize());
-
+  
   int search_start = pos;
   int label_size = search_label.GetSize();
   bool found_label = false;
-
+  
   // Move off the template we are on.
   pos -= label_size;
-
+  
   // Search until we find the complement or exit the memory.
   while (pos >= 0) {
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
-
-    if (inst_set->IsNop( search_genome[pos] )) {
+    
+    if (m_inst_set->IsNop( search_genome[pos] )) {
       // Find the start and end of the label we're in the middle of.
-
+      
       int start_pos = pos;
       int end_pos = pos + 1;
-      while (start_pos > 0 && inst_set->IsNop(search_genome[start_pos - 1])) {
-	start_pos--;
+      while (start_pos > 0 && m_inst_set->IsNop(search_genome[start_pos - 1])) {
+        start_pos--;
       }
       while (end_pos < search_start &&
-	     inst_set->IsNop(search_genome[end_pos])) {
-	end_pos++;
+             m_inst_set->IsNop(search_genome[end_pos])) {
+        end_pos++;
       }
       int test_size = end_pos - start_pos;
-
+      
       // See if this label has the proper sub-label within it.
       int max_offset = test_size - label_size + 1;
       for (int offset = start_pos; offset < start_pos + max_offset; offset++) {
-
-	// Test the number of matches for this offset.
-	int matches;
-	for (matches = 0; matches < label_size; matches++) {
-	  if (search_label[matches] !=
-	      inst_set->GetNopMod(search_genome[offset + matches])) {
-	    break;
-	  }
-	}
-
-	// If we have found it, break out of this loop!
-	if (matches == label_size) {
-	  found_label = true;
-	  break;
-	}
+        
+        // Test the number of matches for this offset.
+        int matches;
+        for (matches = 0; matches < label_size; matches++) {
+          if (search_label[matches] !=
+              m_inst_set->GetNopMod(search_genome[offset + matches])) {
+            break;
+          }
+        }
+        
+        // If we have found it, break out of this loop!
+        if (matches == label_size) {
+          found_label = true;
+          break;
+        }
       }
-
+      
       // If we've found the complement label, set the position to the end of
       // the label we found it in, and break out.
-
+      
       if (found_label == true) {
-	pos = end_pos;
-	break;
+        pos = end_pos;
+        break;
       }
-
+      
       // We haven't found it; jump pos to just before the current label
       // being checked.
       pos = start_pos - 1;
     }
-
+    
     // Jump up a block to the next possible point to find a label,
     pos -= label_size;
   }
-
+  
   // If the label was not found return a -1.
   if (found_label == false) pos = -1;
-
+  
   return pos;
 }
 
@@ -754,35 +736,35 @@
 cHeadMultiMem cHardware4Stack::FindLabel(const cCodeLabel & in_label, int direction)
 {
   assert (in_label.GetSize() > 0);
-
+  
   // IDEALY:
   // Keep making jumps (in the proper direction) equal to the label
   // length.  If we are inside of a label, check its size, and see if
   // any of the sub-labels match properly.
   // FOR NOW:
   // Get something which works, no matter how inefficient!!!
-
+  
   cHeadMultiMem temp_head(this);
-
+  
   while (temp_head.InMemory()) {
     // IDEALY: Analyze the label we are in; see if the one we are looking
     // for could be a sub-label of it.  Skip past it if not.
-
+    
     int i;
     for (i = 0; i < in_label.GetSize(); i++) {
-      if (!inst_set->IsNop(temp_head.GetInst()) ||
-	  in_label[i] != inst_set->GetNopMod(temp_head.GetInst())) {
-	break;
+      if (!m_inst_set->IsNop(temp_head.GetInst()) ||
+          in_label[i] != m_inst_set->GetNopMod(temp_head.GetInst())) {
+        break;
       }
     }
     if (i == GetLabel().GetSize()) {
       temp_head.AbsJump(i - 1);
       return temp_head;
     }
-
+    
     temp_head.AbsJump(direction);     // IDEALY: MAKE LARGER JUMPS
   }
-
+  
   temp_head.AbsSet(-1);
   return temp_head;
 }
@@ -793,64 +775,64 @@
 {
   // cout << "Running FindFullLabel with " << in_label.AsString() <<
   // endl;
-
+  
   assert(in_label.GetSize() > 0); // Trying to find label of 0 size!
-
+  
   cHeadMultiMem temp_head(this);
-
+  
   while (temp_head.InMemory()) {
     // If we are not in a label, jump to the next checkpoint...
-    if (inst_set->IsNop(temp_head.GetInst())) {
+    if (m_inst_set->IsNop(temp_head.GetInst())) {
       temp_head.AbsJump(in_label.GetSize());
       continue;
     }
-
+    
     // Otherwise, rewind to the begining of this label...
-
-    while (!(temp_head.AtFront()) && inst_set->IsNop(temp_head.GetInst(-1)))
+    
+    while (!(temp_head.AtFront()) && m_inst_set->IsNop(temp_head.GetInst(-1)))
       temp_head.AbsJump(-1);
-
+    
     // Calculate the size of the label being checked, and make sure they
     // are equal.
-
+    
     int checked_size = 0;
-    while (inst_set->IsNop(temp_head.GetInst(checked_size))) {
+    while (m_inst_set->IsNop(temp_head.GetInst(checked_size))) {
       checked_size++;
     }
     if (checked_size != in_label.GetSize()) {
       temp_head.AbsJump(checked_size + 1);
       continue;
     }
-
+    
     // cout << "Testing label at line " << temp_head.GetPosition() <<
     // endl;
-
+    
     // ...and do the comparison...
-
+    
     int j;
     bool label_match = true;
     for (j = 0; j < in_label.GetSize(); j++) {
-      if (!inst_set->IsNop(temp_head.GetInst(j)) ||
-	  in_label[j] != inst_set->GetNopMod(temp_head.GetInst(j))) {
-	temp_head.AbsJump(in_label.GetSize() + 1);
-	label_match = false;
-	break;
+      if (!m_inst_set->IsNop(temp_head.GetInst(j)) ||
+          in_label[j] != m_inst_set->GetNopMod(temp_head.GetInst(j))) {
+        temp_head.AbsJump(in_label.GetSize() + 1);
+        label_match = false;
+        break;
       }
     }
-
+    
     if (label_match) {
       // If we have found the label, return the position after it.
       temp_head.AbsJump(j - 1);
       return temp_head;
     }
-
+    
     // We have not found the label... increment i.
-
+    
     temp_head.AbsJump(in_label.GetSize() + 1);
   }
-
+  
   // The label does not exist in this creature.
-
+  
   temp_head.AbsSet(-1);
   return temp_head;
 }
@@ -873,15 +855,15 @@
     Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: new size too small");
     return false; // (inject fails)
   }
-
+  
   GetMemory(mem_space_used).Resize(end_pos);
-
+  
   cCPUMemory injected_code = GetMemory(mem_space_used);
-
+  
   Inject_DoMutations(mut_multiplier, injected_code);
-
+  
   int inject_signal = false;
-
+  
   if(injected_code.GetSize()>0)
     inject_signal = organism->InjectParasite(injected_code);
   
@@ -890,30 +872,30 @@
   //const int num_neighbors = organism->GetNeighborhoodSize();
   //for(unsigned int i=0; i<m_world->GetRandom().GetUInt(num_neighbors); i++)
   //  organism->Rotate(1);
-
+  
   // If we don't have a host, stop here.
   //cOrganism * host_organism = organism->GetNeighbor();
   
- 
+  
   //if(host_organism!=NULL)
   //  {
   //    
   //  }
- 
+  
   //************** CALL ENDS HERE ******************//
-
+  
   //reset the memory space which was injected
   GetMemory(mem_space_used)=cGenome(ConvertToInstruction(mem_space_used)); 
-
+  
   for(int x=0; x<nHardware::NUM_HEADS; x++)
-    {
-      GetHead(x).Reset(IP().GetMemSpace(), this);
-    }
-
+  {
+    GetHead(x).Reset(IP().GetMemSpace(), this);
+  }
+  
   for(int x=0; x<nHardware4Stack::NUM_LOCAL_STACKS; x++)
-    {
-      Stack(x).Clear();
-    }
+  {
+    Stack(x).Clear();
+  }
   
   AdvanceIP() = false;
   
@@ -924,24 +906,24 @@
 bool cHardware4Stack::InjectHost(const cCodeLabel & in_label, const cGenome & inject_code)
 {
   // Make sure the genome will be below max size after injection.
-
+  
   // xxxTEMPORARYxxx - we should have this match injection templates.  For now it simply 
   
-// FIND THE FIRST EMPTY MEMORY SPACE
+  // FIND THE FIRST EMPTY MEMORY SPACE
   int target_mem_space;
   for (target_mem_space = 0; target_mem_space < nHardware4Stack::NUM_MEMORY_SPACES; target_mem_space++)
+  {
+    if(isEmpty(target_mem_space))
     {
-      if(isEmpty(target_mem_space))
-	{
-	  break;
-	}
+      break;
     }
+  }
   
   if (target_mem_space == nHardware4Stack::NUM_MEMORY_SPACES)
-    {
-      return false;
-    }
-
+  {
+    return false;
+  }
+  
   assert(target_mem_space >=0 && target_mem_space < nHardware4Stack::NUM_MEMORY_SPACES);
   
   if(ForkThread()) {
@@ -949,12 +931,12 @@
     cCPUMemory oldcode = GetMemory(target_mem_space);
     GetMemory(target_mem_space) = inject_code;
     GetMemory(target_mem_space).Resize(inject_code.GetSize() + oldcode.GetSize());
-
+    
     // Copies previous instructions to the end of the injected code.
     // Is there a faster way to do this?? -law
     for(int x=0; x<oldcode.GetSize(); x++)
       GetMemory(target_mem_space)[inject_code.GetSize()+x] = oldcode[x];
-  
+    
     // Set instruction flags on the injected code
     for (int i = 0; i < inject_code.GetSize(); i++) {
       memory_array[target_mem_space].FlagInjected(i) = true;
@@ -967,8 +949,8 @@
     
     for(int i=0; i<cur_thread; i++) {
       for(int j=0; j<nHardware::NUM_HEADS; j++) {
-	if(threads[i].heads[j].GetMemSpace()==target_mem_space)
-	  threads[i].heads[j].Jump(inject_code.GetSize());
+        if(threads[i].heads[j].GetMemSpace()==target_mem_space)
+          threads[i].heads[j].Jump(inject_code.GetSize());
       }
     }
     
@@ -979,7 +961,7 @@
       Stack(i).Clear();
     }
   }
-
+  
   return true; // (inject succeeds!)
 }
 
@@ -987,8 +969,8 @@
 {
   // Test if trying to mutate outside of genome...
   assert(mut_point >= 0 && mut_point < GetMemory(0).GetSize());
-
-  GetMemory(0)[mut_point] = GetRandomInst();
+  
+  GetMemory(0)[mut_point] = m_inst_set->GetRandomInst();
   GetMemory(0).FlagMutated(mut_point) = true;
   GetMemory(0).FlagPointMut(mut_point) = true;
   //organism->GetPhenotype().IsMutated() = true;
@@ -998,13 +980,13 @@
 int cHardware4Stack::PointMutate(const double mut_rate)
 {
   const int num_muts =
-    m_world->GetRandom().GetRandBinomial(GetMemory(0).GetSize(), mut_rate);
-
+  m_world->GetRandom().GetRandBinomial(GetMemory(0).GetSize(), mut_rate);
+  
   for (int i = 0; i < num_muts; i++) {
     const int pos = m_world->GetRandom().GetUInt(GetMemory(0).GetSize());
     Mutate(pos);
   }
-
+  
   return num_muts;
 }
 
@@ -1016,67 +998,67 @@
 {
   // Only update triggers should happen from the outside!
   assert(trigger == nMutation::TRIGGER_UPDATE);
-
+  
   // Assume instruction pointer is the intended target (if one is even
   // needed!
-
+  
   return TriggerMutations(trigger, IP());
 }
 
-bool cHardware4Stack::TriggerMutations(int trigger, cHeadMultiMem & cur_head)
+bool cHardware4Stack::TriggerMutations(int trigger, cHeadCPU& cur_head)
 {
   // Collect information about mutations from the organism.
   cLocalMutations & mut_info = organism->GetLocalMutations();
   const tList<cMutation> & mut_list =
     mut_info.GetMutationLib().GetMutationList(trigger);
-
+  
   // If we have no mutations for this trigger, stop here.
   if (mut_list.GetSize() == 0) return false;
   bool has_mutation = false;
-
+  
   // Determine what memory this mutation will be affecting.
   cCPUMemory & target_mem = (trigger == nMutation::TRIGGER_DIVIDE) 
     ? organism->ChildGenome() : GetMemory(0);
-
+  
   // Loop through all mutations associated with this trigger and test them.
   tConstListIterator<cMutation> mut_it(mut_list);
-
+  
   while (mut_it.Next() != NULL) {
     const cMutation * cur_mut = mut_it.Get();
     const int mut_id = cur_mut->GetID();
     const int scope = cur_mut->GetScope();
     const double rate = mut_info.GetRate(mut_id);
     switch (scope) {
-    case nMutation::SCOPE_GENOME:
-      if (TriggerMutations_ScopeGenome(cur_mut, target_mem, cur_head, rate)) {
-	has_mutation = true;
-	mut_info.IncCount(mut_id);
-      }
-      break;
-    case nMutation::SCOPE_LOCAL:
-    case nMutation::SCOPE_PROP:
-      if (TriggerMutations_ScopeLocal(cur_mut, target_mem, cur_head, rate)) {
-	has_mutation = true;
-	mut_info.IncCount(mut_id);
-      }
-      break;
-    case nMutation::SCOPE_GLOBAL:
-    case nMutation::SCOPE_SPREAD:
-      int num_muts =
-	TriggerMutations_ScopeGlobal(cur_mut, target_mem, cur_head, rate);
-      if (num_muts > 0) {
-	has_mutation = true;
-	mut_info.IncCount(mut_id, num_muts);
-      }
-      break;
+      case nMutation::SCOPE_GENOME:
+        if (TriggerMutations_ScopeGenome(cur_mut, target_mem, cur_head, rate)) {
+          has_mutation = true;
+          mut_info.IncCount(mut_id);
+        }
+        break;
+      case nMutation::SCOPE_LOCAL:
+      case nMutation::SCOPE_PROP:
+        if (TriggerMutations_ScopeLocal(cur_mut, target_mem, cur_head, rate)) {
+          has_mutation = true;
+          mut_info.IncCount(mut_id);
+        }
+        break;
+      case nMutation::SCOPE_GLOBAL:
+      case nMutation::SCOPE_SPREAD:
+        int num_muts =
+        TriggerMutations_ScopeGlobal(cur_mut, target_mem, cur_head, rate);
+        if (num_muts > 0) {
+          has_mutation = true;
+          mut_info.IncCount(mut_id, num_muts);
+        }
+          break;
     }
   }
-
+  
   return has_mutation;
 }
 
-bool cHardware4Stack::TriggerMutations_ScopeGenome(const cMutation * cur_mut,
-          cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate)
+bool cHardware4Stack::TriggerMutations_ScopeGenome(const cMutation* cur_mut,
+                                                   cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate)
 {
   // The rate we have stored indicates the probability that a single
   // mutation will occur anywhere in the genome.
@@ -1084,7 +1066,7 @@
   if (m_world->GetRandom().P(rate) == true) {
     // We must create a temporary head and use it to randomly determine the
     // position in the genome to be mutated.
-    cHeadMultiMem tmp_head(cur_head);
+    cHeadCPU tmp_head(cur_head);
     tmp_head.AbsSet(m_world->GetRandom().GetUInt(target_memory.GetSize()));
     TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
     return true;
@@ -1092,12 +1074,12 @@
   return false;
 }
 
-bool cHardware4Stack::TriggerMutations_ScopeLocal(const cMutation * cur_mut,
-          cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate)
+bool cHardware4Stack::TriggerMutations_ScopeLocal(const cMutation* cur_mut,
+                                                  cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate)
 {
   // The rate we have stored is the probability for a mutation at this single
   // position in the genome.
-
+  
   if (m_world->GetRandom().P(rate) == true) {
     TriggerMutations_Body(cur_mut->GetType(), target_memory, cur_head);
     return true;
@@ -1105,70 +1087,57 @@
   return false;
 }
 
-int cHardware4Stack::TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
-          cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate)
+int cHardware4Stack::TriggerMutations_ScopeGlobal(const cMutation* cur_mut,
+                                                  cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate)
 {
   // The probability we have stored is per-site, so we can pull a random
   // number from a binomial distribution to determine the number of mutations
   // that should occur.
-
+  
   const int num_mut =
-    m_world->GetRandom().GetRandBinomial(target_memory.GetSize(), rate);
-
+  m_world->GetRandom().GetRandBinomial(target_memory.GetSize(), rate);
+  
   if (num_mut > 0) {
     for (int i = 0; i < num_mut; i++) {
-      cHeadMultiMem tmp_head(cur_head);
+      cHeadCPU tmp_head(cur_head);
       tmp_head.AbsSet(m_world->GetRandom().GetUInt(target_memory.GetSize()));
       TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
     }
   }
-
+  
   return num_mut;
 }
 
-void cHardware4Stack::TriggerMutations_Body(int type, cCPUMemory & target_memory,
-					 cHeadMultiMem & cur_head)
+void cHardware4Stack::TriggerMutations_Body(int type, cCPUMemory & target_memory, cHeadCPU& cur_head)
 {
   const int pos = cur_head.GetPosition();
-
+  
   switch (type) {
-  case nMutation::TYPE_POINT:
-    target_memory[pos] = GetRandomInst();
-    target_memory.FlagMutated(pos) = true;
-    break;
-  case nMutation::TYPE_INSERT:
-  case nMutation::TYPE_DELETE:
-  case nMutation::TYPE_HEAD_INC:
-  case nMutation::TYPE_HEAD_DEC:
-  case nMutation::TYPE_TEMP:
-  case nMutation::TYPE_KILL:
-  default:
-    cout << "Error: Mutation type not implemented!" << endl;
-    break;
+    case nMutation::TYPE_POINT:
+      target_memory[pos] = m_inst_set->GetRandomInst();
+      target_memory.FlagMutated(pos) = true;
+      break;
+    case nMutation::TYPE_INSERT:
+    case nMutation::TYPE_DELETE:
+    case nMutation::TYPE_HEAD_INC:
+    case nMutation::TYPE_HEAD_DEC:
+    case nMutation::TYPE_TEMP:
+    case nMutation::TYPE_KILL:
+    default:
+      cout << "Error: Mutation type not implemented!" << endl;
+      break;
   };
 }
 
 void cHardware4Stack::ReadInst(const int in_inst)
 {
-  if (inst_set->IsNop( cInstruction(in_inst) )) {
+  if (m_inst_set->IsNop( cInstruction(in_inst) )) {
     GetReadLabel().AddNop(in_inst);
   } else {
     GetReadLabel().Clear();
   }
 }
 
-
-void cHardware4Stack::AdjustHeads()
-{
-  for (int i = 0; i < GetNumThreads(); i++) {
-    for (int j = 0; j < nHardware::NUM_HEADS; j++) {
-      threads[i].heads[j].Adjust();
-    }
-  }
-}
-
-
-
 // This function looks at the current position in the info of a creature,
 // and sets the next_label to be the sequence of nops which follows.  The
 // instruction pointer is left on the last line of the label found.
@@ -1177,15 +1146,15 @@
 {
   int count = 0;
   cHeadMultiMem * inst_ptr = &( IP() );
-
+  
   GetLabel().Clear();
-
-  while (inst_set->IsNop(inst_ptr->GetNextInst()) &&
-	 (count < max_size)) {
+  
+  while (m_inst_set->IsNop(inst_ptr->GetNextInst()) &&
+         (count < max_size)) {
     count++;
     inst_ptr->Advance();
-    GetLabel().AddNop(inst_set->GetNopMod(inst_ptr->GetInst()));
-
+    GetLabel().AddNop(m_inst_set->GetNopMod(inst_ptr->GetInst()));
+    
     // If this is the first line of the template, mark it executed.
     if (GetLabel().GetSize() <=	m_world->GetConfig().MAX_LABEL_EXE_SIZE.Get()) {
       inst_ptr->FlagExecuted() = true;
@@ -1198,22 +1167,22 @@
 {
   const int num_threads = GetNumThreads();
   if (num_threads == m_world->GetConfig().MAX_CPU_THREADS.Get()) return false;
-
+  
   // Make room for the new thread.
   threads.Resize(num_threads + 1);
-
+  
   //IP().Advance();
-
+  
   // Initialize the new thread to the same values as the current one.
   threads[num_threads] = threads[cur_thread]; 
-
+  
   // Find the first free bit in thread_id_chart to determine the new
   // thread id.
   int new_id = 0;
   while ( (thread_id_chart >> new_id) & 1 == 1) new_id++;
   threads[num_threads].SetID(new_id);
   thread_id_chart |= (1 << new_id);
-
+  
   return true;
 }
 
@@ -1228,25 +1197,25 @@
 {
   // Make sure that there is always at least one thread...
   if (GetNumThreads() == 1) return false;
-
+  
   // Note the current thread and set the current back one.
   const int kill_thread = cur_thread;
   PrevThread();
   
   // Turn off this bit in the thread_id_chart...
   thread_id_chart ^= 1 << threads[kill_thread].GetID();
-
+  
   // Copy the last thread into the kill position
   const int last_thread = GetNumThreads() - 1;
   if (last_thread != kill_thread) {
     threads[kill_thread] = threads[last_thread];
   }
-
+  
   // Kill the thread!
   threads.Resize(GetNumThreads() - 1);
-
+  
   if (cur_thread > kill_thread) cur_thread--;
-
+  
   return true;
 }
 
@@ -1259,10 +1228,10 @@
 inline int cHardware4Stack::FindModifiedStack(int default_stack)
 {
   assert(default_stack < nHardware4Stack::NUM_STACKS);  // Stack ID too high.
-
-  if (GetInstSet().IsNop(IP().GetNextInst())) {
+  
+  if (m_inst_set->IsNop(IP().GetNextInst())) {
     IP().Advance();
-    default_stack = GetInstSet().GetNopMod(IP().GetInst());
+    default_stack = m_inst_set->GetNopMod(IP().GetInst());
     IP().FlagExecuted() = true;
   }
   return default_stack;
@@ -1271,10 +1240,10 @@
 inline int cHardware4Stack::FindModifiedHead(int default_head)
 {
   assert(default_head < nHardware::NUM_HEADS); // Head ID too high.
-
-  if (GetInstSet().IsNop(IP().GetNextInst())) {
+  
+  if (m_inst_set->IsNop(IP().GetNextInst())) {
     IP().Advance();    
-    int nop_head = GetInstSet().GetNopMod(IP().GetInst());
+    int nop_head = m_inst_set->GetNopMod(IP().GetInst());
     if (nop_head < nHardware::NUM_HEADS) default_head = nop_head;
     IP().FlagExecuted() = true;
   }
@@ -1293,13 +1262,13 @@
 }
 
 bool cHardware4Stack::Divide_CheckViable(const int parent_size,
-				      const int child_size, const int mem_space)
+                                         const int child_size, const int mem_space)
 {
   // Make sure the organism is okay with dividing now...
   if (organism->Divide_CheckViable() == false) return false; // (divide fails)
-
+  
   // Make sure that neither parent nor child will be below the minimum size.
-
+  
   const int genome_size = organism->GetGenome().GetSize();
   const double size_range = m_world->GetConfig().CHILD_SIZE_RANGE.Get();
   const int min_size = Max(MIN_CREATURE_SIZE, (int) (genome_size/size_range));
@@ -1307,46 +1276,46 @@
   
   if (child_size < min_size || child_size > max_size) {
     Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Invalid offspring length (%d)", child_size));
+          cStringUtil::Stringf("Invalid offspring length (%d)", child_size));
     return false; // (divide fails)
   }
-
+  
   // Count the number of lines executed in the parent, and make sure the
   // specified fraction has been reached.
-
+  
   int executed_size = 0;
   for (int i = 0; i < parent_size; i++) {
     if (GetMemory(0).FlagExecuted(i)) executed_size++;
   }
-
+  
   const int min_exe_lines = (int) (parent_size * m_world->GetConfig().MIN_EXE_LINES.Get());
   if (executed_size < min_exe_lines) {
     Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Too few executed lines (%d < %d)",
-			       executed_size, min_exe_lines));
+          cStringUtil::Stringf("Too few executed lines (%d < %d)",
+                               executed_size, min_exe_lines));
     return false; // (divide fails)
   }
 	
   // Count the number of lines which were copied into the child, and make
   // sure the specified fraction has been reached.
-
+  
   int copied_size = 0;
   for (int i = 0; i < GetMemory(mem_space).GetSize(); i++) {
     if (GetMemory(mem_space).FlagCopied(i)) copied_size++;
-   }
-
+  }
+  
   const int min_copied =  (int) (child_size * m_world->GetConfig().MIN_COPIED_LINES.Get());
   if (copied_size < min_copied) {
     Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Too few copied commands (%d < %d)",
-			       copied_size, min_copied));
+          cStringUtil::Stringf("Too few copied commands (%d < %d)",
+                               copied_size, min_copied));
     return false; // (divide fails)
   }
-
+  
   // Save the information we collected here...
   organism->GetPhenotype().SetLinesExecuted(executed_size);
   organism->GetPhenotype().SetLinesCopied(copied_size);
-
+  
   return true; // (divide succeeds!)
 }
 
@@ -1356,21 +1325,21 @@
   cCPUMemory & child_genome = organism->ChildGenome();
   
   organism->GetPhenotype().SetDivType(mut_multiplier);
-
+  
   // Divide Mutations
   if (organism->TestDivideMut()) {
     const UINT mut_line = m_world->GetRandom().GetUInt(child_genome.GetSize());
-    child_genome[mut_line] = GetRandomInst();
+    child_genome[mut_line] = m_inst_set->GetRandomInst();
     cpu_stats.mut_stats.divide_mut_count++;
   }
-
+  
   // Divide Insertions
   if (organism->TestDivideIns() && child_genome.GetSize() < MAX_CREATURE_SIZE){
     const UINT mut_line = m_world->GetRandom().GetUInt(child_genome.GetSize() + 1);
-    child_genome.Insert(mut_line, GetRandomInst());
+    child_genome.Insert(mut_line, m_inst_set->GetRandomInst());
     cpu_stats.mut_stats.divide_insert_mut_count++;
   }
-
+  
   // Divide Deletions
   if (organism->TestDivideDel() && child_genome.GetSize() > MIN_CREATURE_SIZE){
     const UINT mut_line = m_world->GetRandom().GetUInt(child_genome.GetSize());
@@ -1378,26 +1347,26 @@
     child_genome.Remove(mut_line);
     cpu_stats.mut_stats.divide_delete_mut_count++;
   }
-
+  
   // Divide Mutations (per site)
   if(organism->GetDivMutProb() > 0){
     int num_mut = m_world->GetRandom().GetRandBinomial(child_genome.GetSize(), 
-				   	   organism->GetDivMutProb() / mut_multiplier);
+                                                       organism->GetDivMutProb() / mut_multiplier);
     // If we have lines to mutate...
     if( num_mut > 0 ){
       for (int i = 0; i < num_mut; i++) {
-	int site = m_world->GetRandom().GetUInt(child_genome.GetSize());
-	child_genome[site]=GetRandomInst();
-	cpu_stats.mut_stats.div_mut_count++;
+        int site = m_world->GetRandom().GetUInt(child_genome.GetSize());
+        child_genome[site] = m_inst_set->GetRandomInst();
+        cpu_stats.mut_stats.div_mut_count++;
       }
     }
   }
-
-
+  
+  
   // Insert Mutations (per site)
   if(organism->GetInsMutProb() > 0){
     int num_mut = m_world->GetRandom().GetRandBinomial(child_genome.GetSize(),
-					   organism->GetInsMutProb());
+                                                       organism->GetInsMutProb());
     // If would make creature to big, insert up to MAX_CREATURE_SIZE
     if( num_mut + child_genome.GetSize() > MAX_CREATURE_SIZE ){
       num_mut = MAX_CREATURE_SIZE - child_genome.GetSize();
@@ -1407,28 +1376,28 @@
       // Build a list of the sites where mutations occured
       static int mut_sites[MAX_CREATURE_SIZE];
       for (int i = 0; i < num_mut; i++) {
-	mut_sites[i] = m_world->GetRandom().GetUInt(child_genome.GetSize() + 1);
+        mut_sites[i] = m_world->GetRandom().GetUInt(child_genome.GetSize() + 1);
       }
       // Sort the list
       qsort( (void*)mut_sites, num_mut, sizeof(int), &IntCompareFunction );
       // Actually do the mutations (in reverse sort order)
       for(int i = num_mut-1; i >= 0; i--) {
-	child_genome.Insert(mut_sites[i], GetRandomInst());
-	cpu_stats.mut_stats.insert_mut_count++;
+        child_genome.Insert(mut_sites[i], m_inst_set->GetRandomInst());
+        cpu_stats.mut_stats.insert_mut_count++;
       }
     }
   }
-
-
+  
+  
   // Delete Mutations (per site)
   if( organism->GetDelMutProb() > 0 ){
     int num_mut = m_world->GetRandom().GetRandBinomial(child_genome.GetSize(),
-					   organism->GetDelMutProb());
+                                                       organism->GetDelMutProb());
     // If would make creature too small, delete down to MIN_CREATURE_SIZE
     if (child_genome.GetSize() - num_mut < MIN_CREATURE_SIZE) {
       num_mut = child_genome.GetSize() - MIN_CREATURE_SIZE;
     }
-
+    
     // If we have lines to delete...
     for (int i = 0; i < num_mut; i++) {
       int site = m_world->GetRandom().GetUInt(child_genome.GetSize());
@@ -1437,18 +1406,18 @@
       cpu_stats.mut_stats.delete_mut_count++;
     }
   }
-
+  
   // Mutations in the parent's genome
   if (organism->GetParentMutProb() > 0) {
     for (int i = 0; i < GetMemory(0).GetSize(); i++) {
       if (organism->TestParentMut()) {
-	GetMemory(0)[i] = GetRandomInst();
-	cpu_stats.mut_stats.parent_mut_line_count++;
+        GetMemory(0)[i] = m_inst_set->GetRandomInst();
+        cpu_stats.mut_stats.parent_mut_line_count++;
       }
     }
   }
-
-
+  
+  
   // Count up mutated lines
   for(int i = 0; i < GetMemory(0).GetSize(); i++){
     if (GetMemory(0).FlagPointMut(i) == true) {
@@ -1468,21 +1437,21 @@
   //cCPUMemory & child_genome = organism->ChildGenome();
   
   organism->GetPhenotype().SetDivType(mut_multiplier);
-
+  
   // Divide Mutations
   if (organism->TestDivideMut()) {
     const UINT mut_line = m_world->GetRandom().GetUInt(injected_code.GetSize());
-    injected_code[mut_line] = GetRandomInst();
+    injected_code[mut_line] = m_inst_set->GetRandomInst();
     //cpu_stats.mut_stats.divide_mut_count++;
   }
-
+  
   // Divide Insertions
   if (organism->TestDivideIns() && injected_code.GetSize() < MAX_CREATURE_SIZE){
     const UINT mut_line = m_world->GetRandom().GetUInt(injected_code.GetSize() + 1);
-    injected_code.Insert(mut_line, GetRandomInst());
+    injected_code.Insert(mut_line, m_inst_set->GetRandomInst());
     //cpu_stats.mut_stats.divide_insert_mut_count++;
   }
-
+  
   // Divide Deletions
   if (organism->TestDivideDel() && injected_code.GetSize() > MIN_CREATURE_SIZE){
     const UINT mut_line = m_world->GetRandom().GetUInt(injected_code.GetSize());
@@ -1490,26 +1459,26 @@
     injected_code.Remove(mut_line);
     //cpu_stats.mut_stats.divide_delete_mut_count++;
   }
-
+  
   // Divide Mutations (per site)
   if(organism->GetDivMutProb() > 0){
     int num_mut = m_world->GetRandom().GetRandBinomial(injected_code.GetSize(), 
-				   	   organism->GetDivMutProb() / mut_multiplier);
+                                                       organism->GetDivMutProb() / mut_multiplier);
     // If we have lines to mutate...
     if( num_mut > 0 ){
       for (int i = 0; i < num_mut; i++) {
-	int site = m_world->GetRandom().GetUInt(injected_code.GetSize());
-	injected_code[site]=GetRandomInst();
-	//cpu_stats.mut_stats.div_mut_count++;
+        int site = m_world->GetRandom().GetUInt(injected_code.GetSize());
+        injected_code[site] = m_inst_set->GetRandomInst();
+        //cpu_stats.mut_stats.div_mut_count++;
       }
     }
   }
-
-
+  
+  
   // Insert Mutations (per site)
   if(organism->GetInsMutProb() > 0){
     int num_mut = m_world->GetRandom().GetRandBinomial(injected_code.GetSize(),
-					   organism->GetInsMutProb());
+                                                       organism->GetInsMutProb());
     // If would make creature to big, insert up to MAX_CREATURE_SIZE
     if( num_mut + injected_code.GetSize() > MAX_CREATURE_SIZE ){
       num_mut = MAX_CREATURE_SIZE - injected_code.GetSize();
@@ -1519,28 +1488,28 @@
       // Build a list of the sites where mutations occured
       static int mut_sites[MAX_CREATURE_SIZE];
       for (int i = 0; i < num_mut; i++) {
-	mut_sites[i] = m_world->GetRandom().GetUInt(injected_code.GetSize() + 1);
+        mut_sites[i] = m_world->GetRandom().GetUInt(injected_code.GetSize() + 1);
       }
       // Sort the list
       qsort( (void*)mut_sites, num_mut, sizeof(int), &IntCompareFunction );
       // Actually do the mutations (in reverse sort order)
       for(int i = num_mut-1; i >= 0; i--) {
-	injected_code.Insert(mut_sites[i], GetRandomInst());
-	//cpu_stats.mut_stats.insert_mut_count++;
+        injected_code.Insert(mut_sites[i], m_inst_set->GetRandomInst());
+        //cpu_stats.mut_stats.insert_mut_count++;
       }
     }
   }
-
-
+  
+  
   // Delete Mutations (per site)
   if( organism->GetDelMutProb() > 0 ){
     int num_mut = m_world->GetRandom().GetRandBinomial(injected_code.GetSize(),
-					   organism->GetDelMutProb());
+                                                       organism->GetDelMutProb());
     // If would make creature too small, delete down to MIN_CREATURE_SIZE
     if (injected_code.GetSize() - num_mut < MIN_CREATURE_SIZE) {
       num_mut = injected_code.GetSize() - MIN_CREATURE_SIZE;
     }
-
+    
     // If we have lines to delete...
     for (int i = 0; i < num_mut; i++) {
       int site = m_world->GetRandom().GetUInt(injected_code.GetSize());
@@ -1549,29 +1518,29 @@
       //cpu_stats.mut_stats.delete_mut_count++;
     }
   }
-
+  
   // Mutations in the parent's genome
   if (organism->GetParentMutProb() > 0) {
     for (int i = 0; i < GetMemory(0).GetSize(); i++) {
       if (organism->TestParentMut()) {
-	GetMemory(0)[i] = GetRandomInst();
-	//cpu_stats.mut_stats.parent_mut_line_count++;
+        GetMemory(0)[i] = m_inst_set->GetRandomInst();
+        //cpu_stats.mut_stats.parent_mut_line_count++;
       }
     }
   }
-
+  
   /*
-  // Count up mutated lines
-  for(int i = 0; i < GetMemory(0).GetSize(); i++){
-    if (GetMemory(0).FlagPointMut(i) == true) {
-      cpu_stats.mut_stats.point_mut_line_count++;
-    }
-  }
-  for(int i = 0; i < injected_code.GetSize(); i++){
-    if( injected_code.FlagCopyMut(i) == true) {
-      cpu_stats.mut_stats.copy_mut_line_count++;
-    }
-    }*/
+   // Count up mutated lines
+   for(int i = 0; i < GetMemory(0).GetSize(); i++){
+     if (GetMemory(0).FlagPointMut(i) == true) {
+       cpu_stats.mut_stats.point_mut_line_count++;
+     }
+   }
+   for(int i = 0; i < injected_code.GetSize(); i++){
+     if( injected_code.FlagCopyMut(i) == true) {
+       cpu_stats.mut_stats.copy_mut_line_count++;
+     }
+   }*/
 }
 
 
@@ -1581,16 +1550,16 @@
   cPhenotype & phenotype = organism->GetPhenotype();
   phenotype.CopyTrue() = ( organism->ChildGenome() == organism->GetGenome() );
   phenotype.ChildFertile() = true;
-
+  
   // Only continue if we're supposed to do a fitness test on divide...
   if (organism->GetTestOnDivide() == false) return;
-
+  
   // If this was a perfect copy, then we don't need to worry about any other
   // tests...  Theoretically, we need to worry about the parent changing,
   // but as long as the child is always compared to the original genotype,
   // this won't be an issue.
   if (phenotype.CopyTrue() == true) return;
-
+  
   const double parent_fitness = organism->GetTestFitness();
   const double neut_min = parent_fitness * nHardware::FITNESS_NEUTRAL_MIN;
   const double neut_max = parent_fitness * nHardware::FITNESS_NEUTRAL_MAX;
@@ -1628,7 +1597,7 @@
   if (revert == true) {
     organism->ChildGenome() = organism->GetGenome();
   }
-
+  
   if (sterilize == true) {
     organism->GetPhenotype().ChildFertile() = false;
   }
@@ -1643,10 +1612,10 @@
   // for right now -law
   if(IP().GetMemSpace()!=0)
     return false;
-
+  
   // Make sure this divide will produce a viable offspring.
   if(!Divide_CheckViable(GetMemory(IP().GetMemSpace()).GetSize(), 
-	 		 write_head_pos, mem_space_used)) 
+                         write_head_pos, mem_space_used)) 
     return false;
   
   // Since the divide will now succeed, set up the information to be sent
@@ -1654,69 +1623,69 @@
   cGenome & child_genome = organism->ChildGenome();
   GetMemory(mem_space_used).Resize(write_head_pos);
   child_genome = GetMemory(mem_space_used);
-
+  
   // Handle Divide Mutations...
   Divide_DoMutations(mut_multiplier);
-
+  
   // Many tests will require us to run the offspring through a test CPU;
   // this is, for example, to see if mutations need to be reverted or if
   // lineages need to be updated.
   Divide_TestFitnessMeasures();
-
+  
 #ifdef INSTRUCTION_COSTS
   // reset first time instruction costs
   for (int i = 0; i < inst_ft_cost.GetSize(); i++) {
-    inst_ft_cost[i] = GetInstSet().GetFTCost(cInstruction(i));
+    inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
   }
 #endif
-
+  
   bool parent_alive = organism->ActivateDivide();
-
+  
   //reset the memory of the memory space that has been divided off
   GetMemory(mem_space_used)=cGenome(ConvertToInstruction(mem_space_used)); 
-
+  
   // 3 Division Methods:
   // 1) DIVIDE_METHOD_OFFSPRING - Create a child, leave parent state untouched.
   // 2) DIVIDE_METHOD_SPLIT - Create a child, completely reset state of parent.
   // 3) DIVIDE_METHOD_BIRTH - Create a child, reset state of parent's current thread.
   if(parent_alive && !(m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_OFFSPRING))
+  {
+    
+    if(m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT)
     {
+      //this will wipe out all parasites on a divide.
+      Reset();
       
-      if(m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT)
-	{
-	  //this will wipe out all parasites on a divide.
-	  Reset();
-	  
-	}
-      else if(m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_BIRTH)
-	{
-	  //if this isn't the only thread, get rid of it!
-	  // ***this can cause a concurrency problem if we have 
-	  // multiprocessor support for single organisms...don't 
-	  // think that's happening anytime soon though -law ***
-	  if(!organism->GetPhenotype().IsModified() && GetNumThreads()>1 || 
-	     GetNumThreads()>2)
+    }
+    else if(m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_BIRTH)
+    {
+      //if this isn't the only thread, get rid of it!
+      // ***this can cause a concurrency problem if we have 
+      // multiprocessor support for single organisms...don't 
+      // think that's happening anytime soon though -law ***
+      if(!organism->GetPhenotype().IsModified() && GetNumThreads()>1 || 
+         GetNumThreads()>2)
 	    {
 	      KillThread();
 	    }
-
-	  //this will reset the current thread's heads and stacks.  It will 
-	  //not touch any other threads or memory spaces (ie: parasites)
-	  else
+      
+      //this will reset the current thread's heads and stacks.  It will 
+      //not touch any other threads or memory spaces (ie: parasites)
+      else
 	    {
 	      for(int x=0; x<nHardware::NUM_HEADS; x++)
-		{
-		  GetHead(x).Reset(0, this);
-		}
+        {
+          GetHead(x).Reset(0, this);
+        }
 	      for(int x=0; x<nHardware4Stack::NUM_LOCAL_STACKS; x++)
-		{
-		  Stack(x).Clear();
-		}	  
+        {
+          Stack(x).Clear();
+        }	  
 	    }
-	}
-      AdvanceIP()=false;
     }
-     
+    AdvanceIP()=false;
+  }
+  
   return true;
 }
 
@@ -1728,25 +1697,7 @@
   return ret;
 }
 
-cString cHardware4Stack::GetActiveStackID(int stackID) const
-{
-  if(stackID==nHardware4Stack::STACK_AX)
-    return "AX";
-  else if(stackID==nHardware4Stack::STACK_BX)
-    return "BX";
-  else if(stackID==nHardware4Stack::STACK_CX)
-    return "CX";
-  else if(stackID==nHardware4Stack::STACK_DX)
-    return "DX";
-  else
-    return "";
-}
-  
 
-//////////////////////////
-// And the instructions...
-//////////////////////////
-
 //6
 bool cHardware4Stack::Inst_ShiftR()
 {
@@ -1835,7 +1786,7 @@
 {
   int mem_space_used = GetHead(nHardware::HEAD_WRITE).GetMemSpace();
   int mut_multiplier = 1;
-
+  
   return Divide_Main(mem_space_used, mut_multiplier);
 }
 
@@ -1843,15 +1794,6 @@
 {
   // Unused for the moment...
   return true;
-  //AdjustHeads();
-  //const int divide_pos = GetHead(nHardware::HEAD_READ).GetPosition();
-  //int child_end =  GetHead(nHardware::HEAD_WRITE).GetPosition();
-  //if (child_end == 0) child_end = GetMemory(0).GetSize();
-  //const int extra_lines = GetMemory(0).GetSize() - child_end;
-  //bool ret_val = Divide_Main(divide_pos, extra_lines, mut_multiplier);
-  //// Re-adjust heads.
-  //AdjustHeads();
-  //return ret_val; 
 }
 
 //15
@@ -1860,18 +1802,18 @@
   const int head_id = FindModifiedHead(nHardware::HEAD_READ);
   GetHead(head_id).Adjust();
   sCPUStats & cpu_stats = organism->CPUStats();
-
+  
   // Mutations only occur on the read, for the moment.
   int read_inst = 0;
   if (organism->TestCopyMut()) {
-    read_inst = GetRandomInst().GetOp();
+    read_inst = m_inst_set->GetRandomInst().GetOp();
     cpu_stats.mut_stats.copy_mut_count++;  // @CAO, hope this is good!
   } else {
     read_inst = GetHead(head_id).GetInst().GetOp();
   }
   Stack(nHardware4Stack::STACK_AX).Push(read_inst);
   ReadInst(read_inst);
-
+  
   cpu_stats.mut_stats.copies_exec++;  // @CAO, this too..
   GetHead(head_id).Advance();
   return true;
@@ -1886,19 +1828,19 @@
   
   //commented out for right now...
   if(active_head.GetPosition()>=GetMemory(mem_space_used).GetSize()-1)
-   {
-     GetMemory(mem_space_used).Resize(GetMemory(mem_space_used).GetSize()+1);
-     GetMemory(mem_space_used).Copy(GetMemory(mem_space_used).GetSize()-1, GetMemory(mem_space_used).GetSize()-2);
-   }
-
+  {
+    GetMemory(mem_space_used).Resize(GetMemory(mem_space_used).GetSize()+1);
+    GetMemory(mem_space_used).Copy(GetMemory(mem_space_used).GetSize()-1, GetMemory(mem_space_used).GetSize()-2);
+  }
+  
   active_head.Adjust();
-
+  
   int value = Stack(nHardware4Stack::STACK_AX).Pop();
-  if (value < 0 || value >= GetNumInst()) value = 0;
-
+  if (value < 0 || value >= m_inst_set->GetSize()) value = 0;
+  
   active_head.SetInst(cInstruction(value));
   active_head.FlagCopied() = true;
-
+  
   // Advance the head after write...
   active_head++;
   return true;
@@ -1911,30 +1853,30 @@
   cHeadMultiMem & read_head = GetHead(nHardware::HEAD_READ);
   cHeadMultiMem & write_head = GetHead(nHardware::HEAD_WRITE);
   sCPUStats & cpu_stats = organism->CPUStats();
-
+  
   read_head.Adjust();
   write_head.Adjust();
-
+  
   // TriggerMutations(nMutation::TRIGGER_READ, read_head);
   
   // Do mutations.
   cInstruction read_inst = read_head.GetInst();
   if (organism->TestCopyMut()) {
-    read_inst = GetRandomInst();
+    read_inst = m_inst_set->GetRandomInst();
     cpu_stats.mut_stats.copy_mut_count++; 
     write_head.FlagMutated() = true;
     write_head.FlagCopyMut() = true;
     //organism->GetPhenotype().IsMutated() = true;
   }
   ReadInst(read_inst.GetOp());
-
+  
   cpu_stats.mut_stats.copies_exec++;
-
+  
   write_head.SetInst(read_inst);
   write_head.FlagCopied() = true;  // Set the copied flag...
-
+  
   // TriggerMutations(nMutation::TRIGGER_WRITE, write_head);
-
+  
   read_head.Advance();
   write_head.Advance();
   return true;
@@ -1993,7 +1935,7 @@
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
   GetHead(head_used).Set(Stack(nHardware4Stack::STACK_BX).Pop(), 
-			 GetHead(head_used).GetMemSpace(), this);
+                         GetHead(head_used).GetMemSpace(), this);
   return true;
 }
 
@@ -2002,14 +1944,14 @@
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
   if(head_used != nHardware::HEAD_FLOW)
-    {
-      GetHead(head_used).Set(GetHead(nHardware::HEAD_FLOW));
-      if (head_used == nHardware::HEAD_IP) AdvanceIP() = false;
-    }
+  {
+    GetHead(head_used).Set(GetHead(nHardware::HEAD_FLOW));
+    if (head_used == nHardware::HEAD_IP) AdvanceIP() = false;
+  }
   else
-    {
-      threads[cur_thread].heads[nHardware::HEAD_FLOW]++;
-    }
+  {
+    threads[cur_thread].heads[nHardware::HEAD_FLOW]++;
+  }
   return true;
 }
 
@@ -2020,20 +1962,20 @@
   GetLabel().Rotate(2, nHardware4Stack::NUM_NOPS);
   cHeadMultiMem found_pos = FindLabel(0);
   if(found_pos.GetPosition()-IP().GetPosition()==0)
-    {
-      GetHead(nHardware::HEAD_FLOW).Set(IP().GetPosition()+1, IP().GetMemSpace(), this);
-      // pushing zero into nHardware4Stack::STACK_AX on a missed search makes it difficult to create
-      // a self-replicating organism.  -law
-      //Stack(nHardware4Stack::STACK_AX).Push(0);
-      Stack(nHardware4Stack::STACK_BX).Push(0);
-    }
+  {
+    GetHead(nHardware::HEAD_FLOW).Set(IP().GetPosition()+1, IP().GetMemSpace(), this);
+    // pushing zero into nHardware4Stack::STACK_AX on a missed search makes it difficult to create
+    // a self-replicating organism.  -law
+    //Stack(nHardware4Stack::STACK_AX).Push(0);
+    Stack(nHardware4Stack::STACK_BX).Push(0);
+  }
   else
-    {
-      int search_size = found_pos.GetPosition() - IP().GetPosition() + GetLabel().GetSize() + 1;
-      Stack(nHardware4Stack::STACK_BX).Push(search_size);
-      Stack(nHardware4Stack::STACK_AX).Push(GetLabel().GetSize());
-      GetHead(nHardware::HEAD_FLOW).Set(found_pos);
-    }  
+  {
+    int search_size = found_pos.GetPosition() - IP().GetPosition() + GetLabel().GetSize() + 1;
+    Stack(nHardware4Stack::STACK_BX).Push(search_size);
+    Stack(nHardware4Stack::STACK_AX).Push(GetLabel().GetSize());
+    GetHead(nHardware::HEAD_FLOW).Set(found_pos);
+  }  
   
   return true; 
 }
@@ -2129,7 +2071,7 @@
       Stack(stack_used).Push(Stack(nHardware4Stack::STACK_BX).Top() % Stack(nHardware4Stack::STACK_CX).Top());
   } else {
     Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "mod: modding by 0");
-  return false;
+    return false;
   }
   return true;
 }
@@ -2146,11 +2088,11 @@
 bool cHardware4Stack::Inst_IO()
 {
   const int stack_used = FindModifiedStack(nHardware4Stack::STACK_BX);
-
+  
   // Do the "put" component
   const int value_out = Stack(stack_used).Top();
   organism->DoOutput(value_out);  // Check for tasks compleated.
-
+  
   // Do the "get" component
   const int value_in = organism->GetNextInput();
   Stack(stack_used).Push(value_in);
@@ -2162,39 +2104,39 @@
 {
   bool OK=true;
   const int current_mem_space = IP().GetMemSpace();
-
+  
   for(int x=1; x<nHardware4Stack::NUM_MEMORY_SPACES; x++)
+  {
+    OK=true;
+    
+    int index = (current_mem_space+x) % nHardware4Stack::NUM_MEMORY_SPACES;
+    
+    for(int y=0; y<GetMemory(index).GetSize() && OK; y++)
     {
-      OK=true;
-      
-      int index = (current_mem_space+x) % nHardware4Stack::NUM_MEMORY_SPACES;
-
-      for(int y=0; y<GetMemory(index).GetSize() && OK; y++)
-	{
-	  if(GetMemory(index)[y].GetOp() >= nHardware4Stack::NUM_NOPS)
-	    OK=false; 
-	}
-      for(int y=0; y<GetNumThreads() && OK; y++)
-	{
-	  for(int z=0; z<nHardware::NUM_HEADS; z++)
+      if(GetMemory(index)[y].GetOp() >= nHardware4Stack::NUM_NOPS)
+        OK=false; 
+    }
+    for(int y=0; y<GetNumThreads() && OK; y++)
+    {
+      for(int z=0; z<nHardware::NUM_HEADS; z++)
 	    {
 	      if(threads[y].heads[z].GetMemSpace() == index)
-		OK=false;
+          OK=false;
 	    }
-	}
-      if(OK)
-	return index;
     }
+    if(OK)
+      return index;
+  }
   return -1;
 }
 
 bool cHardware4Stack::isEmpty(int mem_space_used)
 {
   for(int x=0; x<GetMemory(mem_space_used).GetSize(); x++)
-    {
-      if(GetMemory(mem_space_used)[x].GetOp() >= nHardware4Stack::NUM_NOPS)
-	return false;
-    }
+  {
+    if(GetMemory(mem_space_used)[x].GetOp() >= nHardware4Stack::NUM_NOPS)
+      return false;
+  }
   return true;
 }
 
@@ -2209,20 +2151,20 @@
 bool cHardware4Stack::Inst_Inject()
 {
   double mut_multiplier = 1;
-
+  
   return InjectParasite(mut_multiplier);
 }
 
 
 
 /*
-bool cHardware4Stack::Inst_InjectRand()
-{
-  // Rotate to a random facing and then run the normal inject instruction
-  const int num_neighbors = organism->GetNeighborhoodSize();
-  organism->Rotate(m_world->GetRandom().GetUInt(num_neighbors));
-  Inst_Inject();
-  return true;
-}
-
-*/
+ bool cHardware4Stack::Inst_InjectRand()
+ {
+   // Rotate to a random facing and then run the normal inject instruction
+   const int num_neighbors = organism->GetNeighborhoodSize();
+   organism->Rotate(m_world->GetRandom().GetUInt(num_neighbors));
+   Inst_Inject();
+   return true;
+ }
+ 
+ */

Modified: development/source/cpu/cHardware4Stack.h
===================================================================
--- development/source/cpu/cHardware4Stack.h	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHardware4Stack.h	2005-11-17 21:14:48 UTC (rev 402)
@@ -1,40 +1,43 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
+/*
+ *  cHardware4Stack.h
+ *  Avida
+ *
+ *  Created by David on 11/17/05.
+ *  Copyright 2005 Michigan State University. All rights reserved.
+ *  Copyright 1999-2003 California Institute of Technology.
+ *
+ */
 
 #ifndef cHardware4Stack_h
 #define cHardware4Stack_h
 
 #include <iomanip>
 
-#ifndef CPU_MEMORY_HH
+#ifndef cCPUMemory_h
 #include "cCPUMemory.h"
 #endif
-#ifndef CPU_STACK_HH
+#ifndef cCPUStack_h
 #include "cCPUStack.h"
 #endif
-#ifndef DEFS_HH
+#ifndef defs_h
 #include "defs.h"
 #endif
-#ifndef HEAD_MULTI_MEM_HH
+#ifndef cHeadMultiMem_h
 #include "cHeadMultiMem.h"
 #endif
-#ifndef HARDWARE_BASE_HH
+#ifndef cHardwareBase_h
 #include "cHardwareBase.h"
 #endif
-#ifndef HARDWARE_4STACK_CONSTANTS_HH
+#ifndef nHardware4Stack_h
 #include "nHardware4Stack.h"
 #endif
-#ifndef HARDWARE_4STACK_THREAD_HH
+#ifndef cHardware4Stack_Thread_h
 #include "cHardware4Stack_Thread.h"
 #endif
-#ifndef STRING_HH
+#ifndef cString_h
 #include "cString.h"
 #endif
-#ifndef TARRAY_HH
+#ifndef tArray_h
 #include "tArray.h"
 #endif
 
@@ -44,12 +47,6 @@
 class cMutation;
 class cInjectGenotype;
 
-#ifdef SINGLE_IO_BUFFER   // For Single IOBuffer vs IOBuffer for each Thread
-# define IO_THREAD 0
-#else
-# define IO_THREAD cur_thread
-#endif
-
 /**
  * Each organism may have a cHardware4Stack structure which keeps track of the
  * current status of all the components of the simulated hardware.
@@ -88,10 +85,6 @@
   int thread_id_chart;
   int cur_thread;
 
-  // Flags...
-  bool mal_active;         // Has an allocate occured since last dividehe?
-  //bool advance_ip;         // Should the IP advance after this instruction?
-
   // Instruction costs...
 #ifdef INSTRUCTION_COSTS
   tArray<int> inst_cost;
@@ -106,289 +99,194 @@
   // Keeps track of fractional instructions that carry over into next update
   float inst_remainder; 
 
+  bool SingleProcess_PayCosts(const cInstruction & cur_inst);
+  bool SingleProcess_ExecuteInst(const cInstruction & cur_inst);
+  
+  
+  // --------  Stack Manipulation...  --------
+  inline cCPUStack& Stack(int stack_id); 
+  inline const cCPUStack& Stack(int stack_id) const;
+  inline cCPUStack& Stack(int stack_id, int in_thread);
+  inline const cCPUStack& Stack(int stack_id, int in_thread) const;
+  
+  
+  // --------  Head Manipulation (including IP)  --------
+  const bool& AdvanceIP() const { return threads[cur_thread].advance_ip; }
+  bool& AdvanceIP() { return threads[cur_thread].advance_ip; }
+  
+  
+  // --------  Label Manipulation  -------
+  void ReadLabel(int max_size=nHardware::MAX_LABEL_SIZE);
+  cHeadMultiMem FindLabel(int direction);
+  int FindLabel_Forward(const cCodeLabel& search_label, const cGenome& search_genome, int pos);
+  int FindLabel_Backward(const cCodeLabel& search_label, const cGenome& search_genome, int pos);
+  cHeadMultiMem FindLabel(const cCodeLabel& in_label, int direction);
+  cHeadMultiMem FindFullLabel(const cCodeLabel& in_label);
+  const cCodeLabel & GetReadLabel() const { return threads[cur_thread].read_label; }
+  cCodeLabel & GetReadLabel() { return threads[cur_thread].read_label; }
+  
+
+  bool TriggerMutations_ScopeGenome(const cMutation * cur_mut,
+                                    cCPUMemory & target_memory, cHeadCPU& cur_head, const double rate);
+  bool TriggerMutations_ScopeLocal(const cMutation * cur_mut,
+                                   cCPUMemory & target_memory, cHeadCPU& cur_head, const double rate);
+  int TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
+                                   cCPUMemory & target_memory, cHeadCPU& cur_head, const double rate);
+  void TriggerMutations_Body(int type, cCPUMemory & target_memory, cHeadCPU& cur_head);
+  
+  // ---------- Instruction Helpers -----------
+  int FindModifiedStack(int default_stack);
+  int FindModifiedHead(int default_head);
+  int FindComplementStack(int base_stack);
+  
+  void Fault(int fault_loc, int fault_type, cString fault_desc=""); 
+  bool Allocate_Necro(const int new_size);
+  bool Allocate_Random(const int old_size, const int new_size);
+  bool Allocate_Default(const int new_size);
+  bool Allocate_Main(const int allocated_size);
+  
+  bool Divide_Main(const int mem_space_used, double mut_multiplier=1);
+  bool Divide_CheckViable(const int parent_size, const int child_size, const int mem_space);
+  void Divide_DoMutations(double mut_multiplier=1);
+  void Inject_DoMutations(double mut_multiplier, cCPUMemory & injected_code);
+  void Divide_TestFitnessMeasures();
+  void Mutate(const int mut_point);
+  
+  bool HeadCopy_ErrorCorrect(double reduction);
+  bool Inst_HeadDivideMut(double mut_multiplier=1);
+
+  bool InjectParasite(double mut_multiplier);
+
+  void ReadInst(const int in_inst);
+  
+  cString ConvertToInstruction(int mem_space_used);
+  
+  int FindFirstEmpty();
+  bool isEmpty(int mem_space_used);
+  inline int NormalizeMemSpace(int mem_space) const;
+  
+  
 public:
   cHardware4Stack(cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set);
   explicit cHardware4Stack(const cHardware4Stack &);
   ~cHardware4Stack() { ; }
-  static cInstLibBase *GetInstLib();
+  static cInstLibBase* GetInstLib();
   static cString GetDefaultInstFilename() { return "inst_lib.4stack"; }
-  static void WriteDefaultInstSet() { ; }
 
   void Reset();
   void SingleProcess();
-  bool SingleProcess_PayCosts(const cInstruction & cur_inst);
-  bool SingleProcess_ExecuteInst(const cInstruction & cur_inst);
   void ProcessBonusInst(const cInstruction & inst);
-  void LoadGenome(const cGenome & new_genome);
 
   // --------  Helper methods  --------
+  int GetType() const { return HARDWARE_TYPE_CPU_4STACK; }
   bool OK();
   void PrintStatus(std::ostream& fp);
 
 
-  // --------  Flag Accessors --------
-  bool GetMalActive() const   { return mal_active; }
-
   // --------  Stack Manipulation...  --------
-  //void StackFlip();
   inline int GetStack(int depth=0, int stack_id=-1, int in_thread=-1) const;
-  //inline void StackClear();
-  //inline void SwitchStack();
-  cString GetActiveStackID(int stackID) const;
-  //retrieves appropriate stack
-  inline cCPUStack & Stack(int stack_id); 
-  inline const cCPUStack & Stack(int stack_id) const;
-  inline cCPUStack & Stack(int stack_id, int in_thread);
-  inline const cCPUStack & Stack(int stack_id, int in_thread) const;
 
+  
   // --------  Head Manipulation (including IP)  --------
-  inline void SetActiveHead(const int new_head)
-  { threads[cur_thread].cur_head = (UCHAR) new_head; }
+  const cHeadMultiMem& GetHead(int head_id) const { return threads[cur_thread].heads[head_id]; }
+  cHeadMultiMem& GetHead(int head_id) { return threads[cur_thread].heads[head_id];}
+  const cHeadMultiMem& GetHead(int head_id, int thread) const { return threads[thread].heads[head_id]; }
+  cHeadMultiMem& GetHead(int head_id, int thread) { return threads[thread].heads[head_id];}
 
-  int GetCurHead() const { return threads[cur_thread].cur_head; }
-  
-  const cHeadMultiMem & GetHead(int head_id) const
-  { return threads[cur_thread].heads[head_id]; }
-  cHeadMultiMem & GetHead(int head_id) 
-  { return threads[cur_thread].heads[head_id];}
-  
-  const cHeadMultiMem & GetHead(int head_id, int thread) const
-  { return threads[thread].heads[head_id]; }
-  cHeadMultiMem & GetHead(int head_id, int thread) 
-  { return threads[thread].heads[head_id];}
+  const cHeadMultiMem& IP() const { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
+  cHeadMultiMem& IP() { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
+  const cHeadMultiMem& IP(int thread) const { return threads[thread].heads[nHardware::HEAD_IP]; }
+  cHeadMultiMem& IP(int thread) { return threads[thread].heads[nHardware::HEAD_IP]; }
 
-  const cHeadMultiMem & GetActiveHead() const { return GetHead(GetCurHead()); }
-  cHeadMultiMem & GetActiveHead() { return GetHead(GetCurHead()); }
-
-  void AdjustHeads();
-
-  inline const cHeadMultiMem & IP() const
-    { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
-  inline cHeadMultiMem & IP() { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
-
-  inline const cHeadMultiMem & IP(int thread) const
-  { return threads[thread].heads[nHardware::HEAD_IP]; }
-  inline cHeadMultiMem & IP(int thread) 
-  { return threads[thread].heads[nHardware::HEAD_IP]; }
-
-
-  inline const bool & AdvanceIP() const
-    { return threads[cur_thread].advance_ip; }
-  inline bool & AdvanceIP() { return threads[cur_thread].advance_ip; }
-
+  
   // --------  Label Manipulation  -------
-  void ReadLabel(int max_size=nHardware::MAX_LABEL_SIZE);
-  const cCodeLabel & GetLabel() const 
-    { return threads[cur_thread].next_label; }
+  const cCodeLabel & GetLabel() const { return threads[cur_thread].next_label; }
   cCodeLabel & GetLabel() { return threads[cur_thread].next_label; }
-  const cCodeLabel & GetReadLabel() const
-    { return threads[cur_thread].read_label; }
-  cCodeLabel & GetReadLabel() { return threads[cur_thread].read_label; }
 
 
+  // --------  Memory Manipulation  --------
+  cCPUMemory& GetMemory() { return memory_array[0]; }
+  const cCPUMemory& GetMemory() const { return memory_array[0]; }
+  cCPUMemory& GetMemory(int mem_space) { return memory_array[NormalizeMemSpace(mem_space)]; }
+  const cCPUMemory& GetMemory(int mem_space) const { return memory_array[NormalizeMemSpace(mem_space)]; }
+  
+  
   // --------  Register Manipulation  --------
-  //int Register(int reg_id) const { return threads[cur_thread].reg[reg_id]; }
-  //int & Register(int reg_id) { return threads[cur_thread].reg[reg_id]; }
+  const int GetRegister(int reg_id) const { return Stack(reg_id).Peek(); }
+  int& GetRegister(int reg_id) { return Stack(reg_id).Peek(); }
 
-  // --------  Memory Manipulation  --------}
-  inline cCPUMemory & GetMemory();
-  inline cCPUMemory & GetMemory(int mem_space);
-  inline const cCPUMemory & GetMemory(int mem_space) const;
-  inline const cCPUMemory & GetMemory() const;
-
+  
   // --------  Thread Manipulation  --------
   bool ForkThread(); // Adds a new thread based off of cur_thread.
   bool KillThread(); // Kill the current thread!
   inline void PrevThread(); // Shift the current thread in use.
   inline void NextThread();
   inline void SetThread(int value);
-  inline cInjectGenotype * GetCurThreadOwner(); 
-  inline cInjectGenotype * GetThreadOwner(int in_thread);
-  inline void SetThreadOwner(cInjectGenotype * in_genotype);
-
-  // --------  Tests  --------
-
+  cInjectGenotype* GetCurThreadOwner() { return threads[cur_thread].owner; }
+  cInjectGenotype* GetThreadOwner(int in_thread) { return threads[in_thread].owner; }
+  void SetThreadOwner(cInjectGenotype* in_genotype) { threads[cur_thread].owner = in_genotype; }
+	
+  
+  // --------  Parasite Stuff  --------
   int TestParasite() const;
+  bool InjectHost(const cCodeLabel& in_label, const cGenome & injection);
+  int InjectThread(const cCodeLabel&, const cGenome&) { return -1; }
 
+  
   // --------  Accessors  --------
-  //int GetThreadTimeUsed() const { return thread_time_used; }
   int GetNumThreads() const     { return threads.GetSize(); }
   int GetCurThread() const      { return cur_thread; }
   int GetCurThreadID() const    { return threads[cur_thread].GetID(); }
-
   int GetThreadDist() const {
     if (GetNumThreads() == 1) return 0;
-    return threads[0].heads[nHardware::HEAD_IP].GetPosition() -
-      threads[1].heads[nHardware::HEAD_IP].GetPosition();
+    return threads[0].heads[nHardware::HEAD_IP].GetPosition() - threads[1].heads[nHardware::HEAD_IP].GetPosition();
   }
-
-  // Complex label manipulation...
-  cHeadMultiMem FindLabel(int direction);
-  int FindLabel_Forward(const cCodeLabel & search_label,
-			  const cGenome & search_genome, int pos);
-  int FindLabel_Backward(const cCodeLabel & search_label,
-			  const cGenome & search_genome, int pos);
-  cHeadMultiMem FindLabel(const cCodeLabel & in_label, int direction);
-  cHeadMultiMem FindFullLabel(const cCodeLabel & in_label);
-
-  int GetType() const { return HARDWARE_TYPE_CPU_4STACK; }
-  bool InjectParasite(double mut_multiplier);
-  bool InjectHost(const cCodeLabel & in_label, const cGenome & injection);
-  int InjectThread(const cCodeLabel &, const cGenome &) { return -1; }
-  void Mutate(const int mut_point);
-  int PointMutate(const double mut_rate);
-  int FindFirstEmpty();
-  bool isEmpty(int mem_space_used);
-
+	
+  
+  // --------  Mutation  --------
+  int PointMutate(const double mut_rate);  
   bool TriggerMutations(int trigger);
-  bool TriggerMutations(int trigger, cHeadMultiMem & cur_head);
-  bool TriggerMutations_ScopeGenome(const cMutation * cur_mut,
-        cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate);
-  bool TriggerMutations_ScopeLocal(const cMutation * cur_mut,
-        cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate);
-  int TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
-        cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate);
-  void TriggerMutations_Body(int type, cCPUMemory & target_memory,
-			     cHeadMultiMem & cur_head);
+  bool TriggerMutations(int trigger, cHeadCPU& cur_head);
+  
 
-  void ReadInst(const int in_inst);
-
-  //void InitInstSet(const cString & filename, cInstSet & inst_set);
-  cString ConvertToInstruction(int mem_space_used);
-
-
 private:
- 
- /////////---------- Instruction Helpers ------------//////////
-
-  int FindModifiedStack(int default_stack);
-  int FindModifiedHead(int default_head);
-  int FindComplementStack(int base_stack);
-
-  void Fault(int fault_loc, int fault_type, cString fault_desc=""); 
-  bool Allocate_Necro(const int new_size);
-  bool Allocate_Random(const int old_size, const int new_size);
-  bool Allocate_Default(const int new_size);
-  bool Allocate_Main(const int allocated_size);
-
-  bool Divide_Main(const int mem_space_used, double mut_multiplier=1);
-  bool Divide_CheckViable(const int parent_size, const int child_size, const int mem_space);
-  void Divide_DoMutations(double mut_multiplier=1);
-  void Inject_DoMutations(double mut_multiplier, cCPUMemory & injected_code);
-  void Divide_TestFitnessMeasures();
-
-  bool HeadCopy_ErrorCorrect(double reduction);
-  bool Inst_HeadDivideMut(double mut_multiplier=1);
-
-public:
-  /////////---------- Instruction Library ------------//////////
-
-  //6
+  // ---------- Instruction Library -----------
   bool Inst_ShiftR();
-  //7
   bool Inst_ShiftL();
-  //8
   bool Inst_Val_Nand();
-  //9
   bool Inst_Val_Add();
-  //10
   bool Inst_Val_Sub();
-  //11
   bool Inst_Val_Mult();
-  //12
   bool Inst_Val_Div();
-  //13
   bool Inst_SetMemory();
-  //14
   bool Inst_Divide();
-  //15
   bool Inst_HeadRead();
-  //16
   bool Inst_HeadWrite();
-  //??
   bool Inst_HeadCopy();
-  //17
   bool Inst_IfEqual();
-  //18
   bool Inst_IfNotEqual();
-  //19
   bool Inst_IfLess();
-  //20
   bool Inst_IfGreater();
-  //21
   bool Inst_HeadPush();
-  //22
   bool Inst_HeadPop();
-  //23
   bool Inst_HeadMove();
-  //24
   bool Inst_Search();
-  //25
   bool Inst_PushNext();
-  //26
   bool Inst_PushPrevious();
-  //27
   bool Inst_PushComplement();
-  //28
   bool Inst_ValDelete();
-  //29
   bool Inst_ValCopy();
-  //30
   bool Inst_ForkThread();
-  //31
   bool Inst_IfLabel();
-  //32
   bool Inst_Increment();
-  //33
   bool Inst_Decrement();
-  //34
   bool Inst_Mod();
-  //35 
   bool Inst_KillThread();
-  //36
   bool Inst_IO();
-  //37
-  bool Inst_Inject();
-  
-  /*
-  bool Inst_InjectRand();
-  bool Inst_InjectThread();
-  bool Inst_Repro();
-  */
- 
+  bool Inst_Inject();  
 };
 
 
-//////////////////
-//  cHardware4Stack
-//////////////////
-
-//Not used, but here to satisfy the requirements of HardwareBase
-inline const cCPUMemory & cHardware4Stack::GetMemory() const
-{
-  return memory_array[0];
-}
-
-//Not used, but here to satisfy the requirements of HardwareBase 
-inline cCPUMemory & cHardware4Stack::GetMemory()
-{
-  return memory_array[0];
-}
-
-inline const cCPUMemory & cHardware4Stack::GetMemory(int mem_space) const
-{
-  if(mem_space >= nHardware4Stack::NUM_MEMORY_SPACES)
-    mem_space %= nHardware4Stack::NUM_MEMORY_SPACES;
-  return memory_array[mem_space];
-}
-
-inline cCPUMemory & cHardware4Stack::GetMemory(int mem_space)
-{
- if(mem_space >= nHardware4Stack::NUM_MEMORY_SPACES)
-    mem_space %= nHardware4Stack::NUM_MEMORY_SPACES;
-  return memory_array[mem_space];
-}
-
 inline void cHardware4Stack::NextThread()
 {
   cur_thread++;
@@ -407,30 +305,6 @@
     cur_thread=value;
 }
 
-inline cInjectGenotype * cHardware4Stack::GetCurThreadOwner() 
-{ 
-  return threads[cur_thread].owner; 
-}
-
-inline cInjectGenotype * cHardware4Stack::GetThreadOwner(int thread) 
-{ 
-  return threads[thread].owner; 
-}
-
-inline void cHardware4Stack::SetThreadOwner(cInjectGenotype * in_genotype)
-{ 
-  threads[cur_thread].owner = in_genotype; 
-}
-
-/*inline void cHardware4Stack::StackFlip()
-{
-  if (threads[cur_thread].cur_stack == 0) {
-    threads[cur_thread].stack.Flip();
-  } else {
-    global_stack.Flip();
-  }
-}*/
-
 inline int cHardware4Stack::GetStack(int depth, int stack_id, int in_thread) const
 {
   if(stack_id<0 || stack_id>nHardware4Stack::NUM_STACKS) stack_id=0;
@@ -441,22 +315,6 @@
   return Stack(stack_id, in_thread).Get(depth);
 }
 
-//inline void cHardware4Stack::StackClear()
-//{
-  
-  //if (threads[cur_thread].cur_stack == 0) {
-  //  threads[cur_thread].stack.Clear();
-  //} else {
-  //  global_stack.Clear();
-  //}
-//}
-
-//inline void cHardware4Stack::SwitchStack()
-//{
-//  threads[cur_thread].cur_stack++;
-//  if (threads[cur_thread].cur_stack > 1) threads[cur_thread].cur_stack = 0;
-//}
-
 inline cCPUStack& cHardware4Stack::Stack(int stack_id)
 {
   if(stack_id >= nHardware4Stack::NUM_STACKS)
@@ -507,4 +365,11 @@
     return global_stacks[stack_id % nHardware4Stack::NUM_LOCAL_STACKS];
 }
 
+inline int cHardware4Stack::NormalizeMemSpace(int mem_space) const
+{
+  if(mem_space >= nHardware4Stack::NUM_MEMORY_SPACES)
+    mem_space %= nHardware4Stack::NUM_MEMORY_SPACES;
+  return mem_space;
+}
+
 #endif

Modified: development/source/cpu/cHardwareBase.cc
===================================================================
--- development/source/cpu/cHardwareBase.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHardwareBase.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -7,36 +7,11 @@
 
 #include "cHardwareBase.h"
 
-#include "cInstSet.h"
-
-using namespace std;
-
-cHardwareBase::cHardwareBase(cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set)
-  : m_world(world)
-  , organism(in_organism)
-  , inst_set(in_inst_set)
-  , viewer_lock(-1)
-  , m_tracer(NULL)
+cHardwareBase::~cHardwareBase()
 {
-  assert(inst_set->OK());
-  assert(organism != NULL);
 }
 
 bool cHardwareBase::Inst_Nop()          // Do Nothing.
 {
   return true;
 }
-
-int cHardwareBase::GetNumInst()
-{
-  assert(inst_set != NULL);
-  return inst_set->GetSize();
-}
-
-
-cInstruction cHardwareBase::GetRandomInst()
-{
-  assert(inst_set != NULL);
-  return inst_set->GetRandomInst();
-}
-

Modified: development/source/cpu/cHardwareBase.h
===================================================================
--- development/source/cpu/cHardwareBase.h	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHardwareBase.h	2005-11-17 21:14:48 UTC (rev 402)
@@ -1,86 +1,131 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2003 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
+/*
+ *  cHardwareBase.h
+ *  Avida
+ *
+ *  Created by David on 11/17/05.
+ *  Copyright 2005 Michigan State University. All rights reserved.
+ *  Copyright 1999-2003 California Institute of Technology.
+ *
+ */
 
-#ifndef HARDWARE_BASE_HH
-#define HARDWARE_BASE_HH
+#ifndef cHardwareBase_h
+#define cHardwareBase_h
 
 #include <iostream>
 
-#ifndef INSTRUCTION_HH
-#include "cInstruction.h"
-#endif
-
 using namespace std;
 
 class cCodeLabel;
 class cCPUMemory;
 class cGenome;
 class cHardwareTracer;
-class cInstruction; // aggregate
+class cHeadCPU;
+class cInjectGenotype;
+class cInstruction;
 class cInstSet;
 class cOrganism;
+class cString;
 class cWorld;
 
 class cHardwareBase {
 protected:
   cWorld* m_world;
   cOrganism* organism;       // Organism using this hardware.
-  cInstSet* inst_set;        // Instruction set being used.
-  int viewer_lock;            // Used if the viewer should only lock onto
-                              //  one aspect of the hardware.
+  cInstSet* m_inst_set;        // Instruction set being used.
+  cHardwareTracer* m_tracer; // Set this if you want execution traced.
 
-  cHardwareTracer * m_tracer;         // Set this if you want execution traced.
-
 public:
-  cHardwareBase(cWorld* world, cOrganism * in_organism, cInstSet * in_inst_set);
-  virtual ~cHardwareBase() { ; }
+  cHardwareBase(cWorld* world, cOrganism* in_organism, cInstSet* inst_set)
+    : m_world(world), organism(in_organism), m_inst_set(inst_set), m_tracer(NULL)
+  {
+    assert(organism != NULL);
+  }
+  virtual ~cHardwareBase();
 
   // --------  Organism ---------
-  cOrganism * GetOrganism() { return organism; }
+  cOrganism* GetOrganism() { return organism; }
+  const cInstSet& GetInstSet() { return *m_inst_set; }
 
-  // --------  Instruction Library  --------
-  const cInstSet & GetInstSet() { return *inst_set; }
-  int GetNumInst();
-  cInstruction GetRandomInst();
-  virtual void SetInstSet(cInstSet & in_inst_set) { inst_set = &in_inst_set; }
-
-  // --------  No-Operation Instruction --------
-  bool Inst_Nop();  // A no-operation instruction that does nothing! 
-
-  // --------  Interaction with Viewer --------
-  int & ViewerLock() { return viewer_lock; }
-
+  
   // --------  Core Functionality  --------
   virtual void Reset() = 0;
   virtual void SingleProcess() = 0;
-  virtual void ProcessBonusInst(const cInstruction & inst) = 0;
-  virtual void LoadGenome(const cGenome & new_genome) = 0;
+  virtual void ProcessBonusInst(const cInstruction& inst) = 0;
+  
+  
+  // --------  Helper methods  --------
+  virtual int GetType() const = 0;
   virtual bool OK() = 0;
-
-  // --------  Other Virtual Tools --------
-  virtual int GetType() const = 0;
-  virtual bool InjectHost(const cCodeLabel & in_label,
-		      const cGenome & injection) = 0;
-  virtual int InjectThread(const cCodeLabel & in_label,
-			   const cGenome & injection) = 0;
-
-  // --------  Input and Output --------
   virtual void PrintStatus(std::ostream& fp) = 0;
-
-  void SetTrace(cHardwareTracer * tracer) { m_tracer = tracer; }
-
-
-  // --------  Mutations (Must be Virtual)  --------
+  void SetTrace(cHardwareTracer* tracer) { m_tracer = tracer; }
+  
+  
+  // --------  Stack Manipulation...  --------
+  virtual int GetStack(int depth = 0, int stack_id = -1, int in_thread = -1) const = 0;
+  
+  
+  // --------  Head Manipulation (including IP)  --------
+  virtual const cHeadCPU& GetHead(int head_id) const = 0;
+  virtual cHeadCPU& GetHead(int head_id) = 0;
+  virtual const cHeadCPU& GetHead(int head_id, int thread) const = 0;
+  virtual cHeadCPU& GetHead(int head_id, int thread) = 0;
+  
+  virtual const cHeadCPU& IP() const = 0;
+  virtual cHeadCPU& IP() = 0;
+  virtual const cHeadCPU& IP(int thread) const = 0;
+  virtual cHeadCPU& IP(int thread) = 0;
+  
+  
+  // --------  Label Manipulation  -------
+  virtual const cCodeLabel& GetLabel() const = 0;
+  virtual cCodeLabel& GetLabel() = 0;
+  
+  
+  // --------  Memory Manipulation  --------
+  virtual const cCPUMemory& GetMemory() const = 0;
+  virtual cCPUMemory& GetMemory() = 0;
+  virtual const cCPUMemory& GetMemory(int value) const = 0;
+  virtual cCPUMemory& GetMemory(int value) = 0;
+  
+  
+  // --------  Register Manipulation  --------
+  virtual const int GetRegister(int reg_id) const = 0;
+  virtual int& GetRegister(int reg_id) = 0;
+  
+  
+  // --------  Thread Manipulation  --------
+  virtual bool ForkThread() = 0;
+  virtual bool KillThread() = 0;
+  virtual void PrevThread() = 0;
+  virtual void NextThread() = 0;
+  virtual void SetThread(int value) = 0;
+  virtual cInjectGenotype* GetCurThreadOwner() = 0;
+  virtual cInjectGenotype* GetThreadOwner(int in_thread) = 0;
+  virtual void SetThreadOwner(cInjectGenotype* in_genotype) = 0;
+  
+  
+  // --------  Parasite Stuff  --------
+  virtual int TestParasite() const = 0;
+  virtual bool InjectHost(const cCodeLabel& in_label, const cGenome& injection) = 0;
+  virtual int InjectThread(const cCodeLabel& in_label, const cGenome& injection) = 0;
+  
+  
+  // --------  Accessors  --------
+  virtual int GetNumThreads() const = 0;
+  virtual int GetCurThread() const = 0;
+  virtual int GetCurThreadID() const = 0;
+  virtual int GetThreadDist() const = 0;
+  
+  
+  // --------  Mutation  --------
   virtual int PointMutate(const double mut_rate) = 0;
   virtual bool TriggerMutations(int trigger) = 0;
-
-  // --------  @CAO Should be rethought?  --------
-  virtual cCPUMemory & GetMemory() = 0;
-  virtual cCPUMemory & GetMemory(int) = 0;
+  virtual bool TriggerMutations(int trigger, cHeadCPU& cur_head) = 0;
+  
+  
+protected:
+  // --------  No-Operation Instruction --------
+  bool Inst_Nop();  // A no-operation instruction that does nothing! 
 };
 
 #endif

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHardwareCPU.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -1,10 +1,14 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2004 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
+/*
+ *  cHardwareCPU.cc
+ *  Avida
+ *
+ *  Created by David on 11/17/05.
+ *  Copyright 2005 Michigan State University. All rights reserved.
+ *  Copyright 1999-2003 California Institute of Technology.
+ *
+ */
 
+
 #include "cHardwareCPU.h"
 
 #include "cCPUTestInfo.h"
@@ -29,16 +33,13 @@
 using namespace std;
 
 
-///////////////
-//  cHardwareCPU
-///////////////
-
 const cInstruction cInstLibCPU::inst_error(255);
 const cInstruction cInstLibCPU::inst_default(0);
-cInstLibCPU *cHardwareCPU::GetInstLib(){ return s_inst_slib; }
 
 cInstLibCPU *cHardwareCPU::s_inst_slib = cHardwareCPU::initInstLib();
-cInstLibCPU *cHardwareCPU::initInstLib(void){
+
+cInstLibCPU *cHardwareCPU::initInstLib(void)
+{
   struct cNOPEntryCPU {
     cString name;
     int nop_mod;
@@ -51,74 +52,74 @@
     cNOPEntryCPU("nop-C", nHardwareCPU::REG_CX),
     cNOPEntryCPU("nop-D", nHardwareCPU::REG_DX)
   };
-
+  
   struct cInstEntryCPU { 
     const cString name;
     const tHardwareCPUMethod function;
     const bool is_default;
     const cString desc;
-
+    
     cInstEntryCPU(const cString & _name, tHardwareCPUMethod _fun,
-		  bool _def=false, const cString & _desc="")
+                  bool _def=false, const cString & _desc="")
       : name(_name), function(_fun), is_default(_def), desc(_desc) {}
   };
   static const cInstEntryCPU s_f_array[] = {
     /*
-    Note: all entries of cNOPEntryCPU s_n_array must have corresponding
-    in the same order in cInstEntryCPU s_f_array, and these entries must
-    be the first elements of s_f_array.
-    */
+     Note: all entries of cNOPEntryCPU s_n_array must have corresponding
+     in the same order in cInstEntryCPU s_f_array, and these entries must
+     be the first elements of s_f_array.
+     */
     cInstEntryCPU("nop-A",     &cHardwareCPU::Inst_Nop, true,
-		  "No-operation instruction; modifies other instructions"),
+                  "No-operation instruction; modifies other instructions"),
     cInstEntryCPU("nop-B",     &cHardwareCPU::Inst_Nop, true,
-		  "No-operation instruction; modifies other instructions"),
+                  "No-operation instruction; modifies other instructions"),
     cInstEntryCPU("nop-C",     &cHardwareCPU::Inst_Nop, true,
-		  "No-operation instruction; modifies other instructions"),
+                  "No-operation instruction; modifies other instructions"),
     cInstEntryCPU("nop-D",     &cHardwareCPU::Inst_Nop, true,
-		  "No-operation instruction; modifies other instructions"),
-
+                  "No-operation instruction; modifies other instructions"),
+    
     cInstEntryCPU("NULL",      &cHardwareCPU::Inst_Nop, false,
-		  "True no-operation instruction: does nothing"),
+                  "True no-operation instruction: does nothing"),
     cInstEntryCPU("nop-X",     &cHardwareCPU::Inst_Nop, false,
-		  "True no-operation instruction: does nothing"),
+                  "True no-operation instruction: does nothing"),
     cInstEntryCPU("if-equ-0",  &cHardwareCPU::Inst_If0, false,
-		  "Execute next instruction if ?BX?==0, else skip it"),
+                  "Execute next instruction if ?BX?==0, else skip it"),
     cInstEntryCPU("if-not-0",  &cHardwareCPU::Inst_IfNot0, false,
-		  "Execute next instruction if ?BX?!=0, else skip it"),
+                  "Execute next instruction if ?BX?!=0, else skip it"),
     cInstEntryCPU("if-n-equ",  &cHardwareCPU::Inst_IfNEqu, true,
-		  "Execute next instruction if ?BX?!=?CX?, else skip it"),
+                  "Execute next instruction if ?BX?!=?CX?, else skip it"),
     cInstEntryCPU("if-equ",    &cHardwareCPU::Inst_IfEqu, false,
-		  "Execute next instruction if ?BX?==?CX?, else skip it"),
+                  "Execute next instruction if ?BX?==?CX?, else skip it"),
     cInstEntryCPU("if-grt-0",  &cHardwareCPU::Inst_IfGr0),
     cInstEntryCPU("if-grt",    &cHardwareCPU::Inst_IfGr),
     cInstEntryCPU("if->=-0",   &cHardwareCPU::Inst_IfGrEqu0),
     cInstEntryCPU("if->=",     &cHardwareCPU::Inst_IfGrEqu),
     cInstEntryCPU("if-les-0",  &cHardwareCPU::Inst_IfLess0),
     cInstEntryCPU("if-less",   &cHardwareCPU::Inst_IfLess, true,
-		  "Execute next instruction if ?BX? < ?CX?, else skip it"),
+                  "Execute next instruction if ?BX? < ?CX?, else skip it"),
     cInstEntryCPU("if-<=-0",   &cHardwareCPU::Inst_IfLsEqu0),
     cInstEntryCPU("if-<=",     &cHardwareCPU::Inst_IfLsEqu),
     cInstEntryCPU("if-A!=B",   &cHardwareCPU::Inst_IfANotEqB),
     cInstEntryCPU("if-B!=C",   &cHardwareCPU::Inst_IfBNotEqC),
     cInstEntryCPU("if-A!=C",   &cHardwareCPU::Inst_IfANotEqC),
     cInstEntryCPU("if-bit-1",  &cHardwareCPU::Inst_IfBit1),
-
+    
     cInstEntryCPU("jump-f",    &cHardwareCPU::Inst_JumpF),
     cInstEntryCPU("jump-b",    &cHardwareCPU::Inst_JumpB),
     cInstEntryCPU("jump-p",    &cHardwareCPU::Inst_JumpP),
     cInstEntryCPU("jump-slf",  &cHardwareCPU::Inst_JumpSelf),
     cInstEntryCPU("call",      &cHardwareCPU::Inst_Call),
     cInstEntryCPU("return",    &cHardwareCPU::Inst_Return),
-
+    
     cInstEntryCPU("pop",       &cHardwareCPU::Inst_Pop, true,
-		  "Remove top number from stack and place into ?BX?"),
+                  "Remove top number from stack and place into ?BX?"),
     cInstEntryCPU("push",      &cHardwareCPU::Inst_Push, true,
-		  "Copy number from ?BX? and place it into the stack"),
+                  "Copy number from ?BX? and place it into the stack"),
     cInstEntryCPU("swap-stk",  &cHardwareCPU::Inst_SwitchStack, true,
-		  "Toggle which stack is currently being used"),
+                  "Toggle which stack is currently being used"),
     cInstEntryCPU("flip-stk",  &cHardwareCPU::Inst_FlipStack),
     cInstEntryCPU("swap",      &cHardwareCPU::Inst_Swap, true,
-		  "Swap the contents of ?BX? with ?CX?"),
+                  "Swap the contents of ?BX? with ?CX?"),
     cInstEntryCPU("swap-AB",   &cHardwareCPU::Inst_SwapAB),
     cInstEntryCPU("swap-BC",   &cHardwareCPU::Inst_SwapBC),
     cInstEntryCPU("swap-AC",   &cHardwareCPU::Inst_SwapAC),
@@ -130,18 +131,18 @@
     cInstEntryCPU("set_C=A",   &cHardwareCPU::Inst_CopyRegCA),
     cInstEntryCPU("set_C=B",   &cHardwareCPU::Inst_CopyRegCB),
     cInstEntryCPU("reset",     &cHardwareCPU::Inst_Reset),
-
+    
     cInstEntryCPU("pop-A",     &cHardwareCPU::Inst_PopA),
     cInstEntryCPU("pop-B",     &cHardwareCPU::Inst_PopB),
     cInstEntryCPU("pop-C",     &cHardwareCPU::Inst_PopC),
     cInstEntryCPU("push-A",    &cHardwareCPU::Inst_PushA),
     cInstEntryCPU("push-B",    &cHardwareCPU::Inst_PushB),
     cInstEntryCPU("push-C",    &cHardwareCPU::Inst_PushC),
-
+    
     cInstEntryCPU("shift-r",   &cHardwareCPU::Inst_ShiftR, true,
-		  "Shift bits in ?BX? right by one (divide by two)"),
+                  "Shift bits in ?BX? right by one (divide by two)"),
     cInstEntryCPU("shift-l",   &cHardwareCPU::Inst_ShiftL, true,
-		  "Shift bits in ?BX? left by one (multiply by two)"),
+                  "Shift bits in ?BX? left by one (multiply by two)"),
     cInstEntryCPU("bit-1",     &cHardwareCPU::Inst_Bit1),
     cInstEntryCPU("set-num",   &cHardwareCPU::Inst_SetNum),
     cInstEntryCPU("val-grey",  &cHardwareCPU::Inst_ValGrey),
@@ -150,11 +151,11 @@
     cInstEntryCPU("val-fib",   &cHardwareCPU::Inst_ValFib),
     cInstEntryCPU("val-poly-c",&cHardwareCPU::Inst_ValPolyC),
     cInstEntryCPU("inc",       &cHardwareCPU::Inst_Inc, true,
-		  "Increment ?BX? by one"),
+                  "Increment ?BX? by one"),
     cInstEntryCPU("dec",       &cHardwareCPU::Inst_Dec, true,
-		  "Decrement ?BX? by one"),
+                  "Decrement ?BX? by one"),
     cInstEntryCPU("zero",      &cHardwareCPU::Inst_Zero, false,
-		  "Set ?BX? to zero"),
+                  "Set ?BX? to zero"),
     cInstEntryCPU("neg",       &cHardwareCPU::Inst_Neg),
     cInstEntryCPU("square",    &cHardwareCPU::Inst_Square),
     cInstEntryCPU("sqrt",      &cHardwareCPU::Inst_Sqrt),
@@ -162,16 +163,16 @@
     cInstEntryCPU("minus-17",  &cHardwareCPU::Inst_Minus17),
     
     cInstEntryCPU("add",       &cHardwareCPU::Inst_Add, true,
-		  "Add BX to CX and place the result in ?BX?"),
+                  "Add BX to CX and place the result in ?BX?"),
     cInstEntryCPU("sub",       &cHardwareCPU::Inst_Sub, true,
-		  "Subtract CX from BX and place the result in ?BX?"),
+                  "Subtract CX from BX and place the result in ?BX?"),
     cInstEntryCPU("mult",      &cHardwareCPU::Inst_Mult, false,
-		  "Multiple BX by CX and place the result in ?BX?"),
+                  "Multiple BX by CX and place the result in ?BX?"),
     cInstEntryCPU("div",       &cHardwareCPU::Inst_Div, false,
-		  "Divide BX by CX and place the result in ?BX?"),
+                  "Divide BX by CX and place the result in ?BX?"),
     cInstEntryCPU("mod",       &cHardwareCPU::Inst_Mod),
     cInstEntryCPU("nand",      &cHardwareCPU::Inst_Nand, true,
-		  "Nand BX by CX and place the result in ?BX?"),
+                  "Nand BX by CX and place the result in ?BX?"),
     cInstEntryCPU("nor",       &cHardwareCPU::Inst_Nor),
     cInstEntryCPU("and",       &cHardwareCPU::Inst_And),
     cInstEntryCPU("order",     &cHardwareCPU::Inst_Order),
@@ -194,62 +195,62 @@
     cInstEntryCPU("search-f",  &cHardwareCPU::Inst_SearchF),
     cInstEntryCPU("search-b",  &cHardwareCPU::Inst_SearchB),
     cInstEntryCPU("mem-size",  &cHardwareCPU::Inst_MemSize),
-
+    
     cInstEntryCPU("get",       &cHardwareCPU::Inst_TaskGet),
     cInstEntryCPU("stk-get",   &cHardwareCPU::Inst_TaskStackGet),
     cInstEntryCPU("stk-load",  &cHardwareCPU::Inst_TaskStackLoad),
     cInstEntryCPU("put",       &cHardwareCPU::Inst_TaskPut),
     cInstEntryCPU("IO",        &cHardwareCPU::Inst_TaskIO, true,
-		  "Output ?BX?, and input new number back into ?BX?"),
-
+                  "Output ?BX?, and input new number back into ?BX?"),
+    
     cInstEntryCPU("send",      &cHardwareCPU::Inst_Send),
     cInstEntryCPU("receive",   &cHardwareCPU::Inst_Receive),
     cInstEntryCPU("sense",     &cHardwareCPU::Inst_Sense),
-
+    
     cInstEntryCPU("donate-rnd",  &cHardwareCPU::Inst_DonateRandom),
     cInstEntryCPU("donate-kin",  &cHardwareCPU::Inst_DonateKin),
     cInstEntryCPU("donate-edt",  &cHardwareCPU::Inst_DonateEditDist),
     cInstEntryCPU("donate-NUL",  &cHardwareCPU::Inst_DonateNULL),
-
+    
     cInstEntryCPU("rotate-l",  &cHardwareCPU::Inst_RotateL),
     cInstEntryCPU("rotate-r",  &cHardwareCPU::Inst_RotateR),
-
+    
     cInstEntryCPU("set-cmut",  &cHardwareCPU::Inst_SetCopyMut),
     cInstEntryCPU("mod-cmut",  &cHardwareCPU::Inst_ModCopyMut),
-
+    
     // Threading instructions
     cInstEntryCPU("fork-th",   &cHardwareCPU::Inst_ForkThread),
     cInstEntryCPU("kill-th",   &cHardwareCPU::Inst_KillThread),
     cInstEntryCPU("id-th",     &cHardwareCPU::Inst_ThreadID),
-
+    
     // Head-based instructions
     cInstEntryCPU("h-alloc",   &cHardwareCPU::Inst_MaxAlloc, true,
-		  "Allocate maximum allowed space"),
+                  "Allocate maximum allowed space"),
     cInstEntryCPU("h-divide",  &cHardwareCPU::Inst_HeadDivide, true,
-		  "Divide code between read and write heads."),
+                  "Divide code between read and write heads."),
     cInstEntryCPU("h-read",    &cHardwareCPU::Inst_HeadRead),
     cInstEntryCPU("h-write",   &cHardwareCPU::Inst_HeadWrite),
     cInstEntryCPU("h-copy",    &cHardwareCPU::Inst_HeadCopy, true,
-		  "Copy from read-head to write-head; advance both"),
+                  "Copy from read-head to write-head; advance both"),
     cInstEntryCPU("h-search",  &cHardwareCPU::Inst_HeadSearch, true,
-		  "Find complement template and make with flow head"),
+                  "Find complement template and make with flow head"),
     cInstEntryCPU("h-push",    &cHardwareCPU::Inst_HeadPush),
     cInstEntryCPU("h-pop",     &cHardwareCPU::Inst_HeadPop),
     cInstEntryCPU("set-head",  &cHardwareCPU::Inst_SetHead),
     cInstEntryCPU("adv-head",  &cHardwareCPU::Inst_AdvanceHead),
     cInstEntryCPU("mov-head",  &cHardwareCPU::Inst_MoveHead, true,
-		  "Move head ?IP? to the flow head"),
+                  "Move head ?IP? to the flow head"),
     cInstEntryCPU("jmp-head",  &cHardwareCPU::Inst_JumpHead, true,
-		  "Move head ?IP? by amount in CX register; CX = old pos."),
+                  "Move head ?IP? by amount in CX register; CX = old pos."),
     cInstEntryCPU("get-head",  &cHardwareCPU::Inst_GetHead, true,
-		  "Copy the position of the ?IP? head into CX"),
+                  "Copy the position of the ?IP? head into CX"),
     cInstEntryCPU("if-label",  &cHardwareCPU::Inst_IfLabel, true,
-		  "Execute next if we copied complement of attached label"),
+                  "Execute next if we copied complement of attached label"),
     cInstEntryCPU("if-label2",  &cHardwareCPU::Inst_IfLabel2, true,
-		  "If copied label compl., exec next inst; else SKIP W/NOPS"),
+                  "If copied label compl., exec next inst; else SKIP W/NOPS"),
     cInstEntryCPU("set-flow",  &cHardwareCPU::Inst_SetFlow, true,
-		  "Set flow-head to position in ?CX?"),
-
+                  "Set flow-head to position in ?CX?"),
+    
     cInstEntryCPU("h-copy2",    &cHardwareCPU::Inst_HeadCopy2),
     cInstEntryCPU("h-copy3",    &cHardwareCPU::Inst_HeadCopy3),
     cInstEntryCPU("h-copy4",    &cHardwareCPU::Inst_HeadCopy4),
@@ -259,15 +260,15 @@
     cInstEntryCPU("h-copy8",    &cHardwareCPU::Inst_HeadCopy8),
     cInstEntryCPU("h-copy9",    &cHardwareCPU::Inst_HeadCopy9),
     cInstEntryCPU("h-copy10",   &cHardwareCPU::Inst_HeadCopy10),
-
+    
     cInstEntryCPU("divide-sex",    &cHardwareCPU::Inst_HeadDivideSex),
     cInstEntryCPU("divide-asex",   &cHardwareCPU::Inst_HeadDivideAsex),
-
+    
     cInstEntryCPU("div-sex",    &cHardwareCPU::Inst_HeadDivideSex),
     cInstEntryCPU("div-asex",   &cHardwareCPU::Inst_HeadDivideAsex),
     cInstEntryCPU("div-asex-w",   &cHardwareCPU::Inst_HeadDivideAsexWait),
     cInstEntryCPU("div-sex-MS",   &cHardwareCPU::Inst_HeadDivideMateSelect),
-
+    
     cInstEntryCPU("h-divide1",      &cHardwareCPU::Inst_HeadDivide1),
     cInstEntryCPU("h-divide2",      &cHardwareCPU::Inst_HeadDivide2),
     cInstEntryCPU("h-divide3",      &cHardwareCPU::Inst_HeadDivide3),
@@ -292,7 +293,7 @@
     cInstEntryCPU("h-divide0.05",   &cHardwareCPU::Inst_HeadDivide0_05),
     cInstEntryCPU("h-divide0.01",   &cHardwareCPU::Inst_HeadDivide0_01),
     cInstEntryCPU("h-divide0.001",  &cHardwareCPU::Inst_HeadDivide0_001),
-
+    
     // High-level instructions
     cInstEntryCPU("repro",      &cHardwareCPU::Inst_Repro),
     cInstEntryCPU("repro-A",    &cHardwareCPU::Inst_Repro),
@@ -321,27 +322,27 @@
     cInstEntryCPU("repro-X",    &cHardwareCPU::Inst_Repro),
     cInstEntryCPU("repro-Y",    &cHardwareCPU::Inst_Repro),
     cInstEntryCPU("repro-Z",    &cHardwareCPU::Inst_Repro),
-
+    
     // Suicide
     cInstEntryCPU("kazi",	&cHardwareCPU::Inst_Kazi),
     cInstEntryCPU("die",	&cHardwareCPU::Inst_Die),
-
-
-
+    
+    
+    
     // Placebo instructions
     // nop-x (included with nops)
     cInstEntryCPU("skip",      &cHardwareCPU::Inst_Skip)
   };
-
+  
   const int n_size = sizeof(s_n_array)/sizeof(cNOPEntryCPU);
-
+  
   static cString n_names[n_size];
   static int nop_mods[n_size];
   for (int i = 0; i < n_size; i++){
     n_names[i] = s_n_array[i].name;
     nop_mods[i] = s_n_array[i].nop_mod;
   }
-
+  
   const int f_size = sizeof(s_f_array)/sizeof(cInstEntryCPU);
   static cString f_names[f_size];
   static tHardwareCPUMethod functions[f_size];
@@ -349,21 +350,21 @@
     f_names[i] = s_f_array[i].name;
     functions[i] = s_f_array[i].function;
   }
-
+  
   cInstLibCPU *inst_lib = new cInstLibCPU(
-    n_size,
-    f_size,
-    n_names,
-    f_names,
-    nop_mods,
-    functions
-  );
-
+                                          n_size,
+                                          f_size,
+                                          n_names,
+                                          f_names,
+                                          nop_mods,
+                                          functions
+                                          );
+  
   return inst_lib;
 }
 
-cHardwareCPU::cHardwareCPU(cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set)
-  : cHardwareBase(world, in_organism, in_inst_set)
+cHardwareCPU::cHardwareCPU(cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
+: cHardwareBase(world, in_organism, in_m_inst_set)
 {
   /* FIXME:  reorganize storage of m_functions.  -- kgn */
   m_functions = s_inst_slib->GetFunctions();
@@ -374,7 +375,7 @@
 
 
 cHardwareCPU::cHardwareCPU(const cHardwareCPU &hardware_cpu)
-: cHardwareBase(hardware_cpu.m_world, hardware_cpu.organism, hardware_cpu.inst_set)
+: cHardwareBase(hardware_cpu.m_world, hardware_cpu.organism, hardware_cpu.m_inst_set)
 , m_functions(hardware_cpu.m_functions)
 , memory(hardware_cpu.memory)
 , global_stack(hardware_cpu.global_stack)
@@ -400,29 +401,29 @@
 {
   global_stack.Clear();
   thread_time_used = 0;
-
+  
   // We want to reset to have a single thread.
   threads.Resize(1);
-
+  
   // Reset that single thread.
   threads[0].Reset(this, 0);
   thread_id_chart = 1; // Mark only the first thread as taken...
   cur_thread = 0;
-
+  
   mal_active = false;
-
+  
 #ifdef INSTRUCTION_COSTS
   // instruction cost arrays
-  const int num_inst_cost = GetNumInst();
+  const int num_inst_cost = m_inst_set->GetSize();
   inst_cost.Resize(num_inst_cost);
   inst_ft_cost.Resize(num_inst_cost);
-
+  
   for (int i = 0; i < num_inst_cost; i++) {
-    inst_cost[i] = GetInstSet().GetCost(cInstruction(i));
-    inst_ft_cost[i] = GetInstSet().GetFTCost(cInstruction(i));
+    inst_cost[i] = m_inst_set->GetCost(cInstruction(i));
+    inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
   }
 #endif
-
+  
 }
 
 
@@ -433,23 +434,23 @@
 {
   // Mark this organism as running...
   organism->SetRunning(true);
-
+  
   cPhenotype & phenotype = organism->GetPhenotype();
   phenotype.IncTimeUsed();
   const int num_threads = GetNumThreads();
   if (num_threads > 1) thread_time_used++;
-
+  
   // If we have threads turned on and we executed each thread in a single
   // timestep, adjust the number of instructions executed accordingly.
   const int num_inst_exec = (m_world->GetConfig().THREAD_SLICING_METHOD.Get() == 1) ?
-    num_threads : 1;
+num_threads : 1;
   
   for (int i = 0; i < num_inst_exec; i++) {
     // Setup the hardware for the next instruction to be executed.
     NextThread();
     advance_ip = true;
     IP().Adjust();
-
+    
 #ifdef BREAKPOINTS
     if (IP().FlagBreakpoint() == true) {
       organism->DoBreakpoint();
@@ -460,35 +461,35 @@
     if (m_tracer != NULL) {
       if (cHardwareTracer_CPU * tracer
           = dynamic_cast<cHardwareTracer_CPU *>(m_tracer)
-      ){
+          ){
         tracer->TraceHardware_CPU(*this);
       }
     }
     
     // Find the instruction to be executed
     const cInstruction & cur_inst = IP().GetInst();
-
+    
     // Test if costs have been paid and it is okay to execute this now...
     const bool exec = SingleProcess_PayCosts(cur_inst);
-
+    
     // Now execute the instruction...
     if (exec == true) {
       SingleProcess_ExecuteInst(cur_inst);
-
+      
       // Some instruction (such as jump) may turn advance_ip off.  Ususally
       // we now want to move to the next instruction in the memory.
       if (advance_ip == true) IP().Advance();
     } // if exec
     
   } // Previous was executed once for each thread...
-
+  
   // Kill creatures who have reached their max num of instructions executed
   const int max_executed = organism->GetMaxExecuted();
   if ((max_executed > 0 && phenotype.GetTimeUsed() >= max_executed)
       || phenotype.GetToDie() == true) {
     organism->Die();
   }
-
+  
   organism->SetRunning(false);
 }
 
@@ -500,26 +501,26 @@
 {
 #ifdef INSTRUCTION_COSTS
   assert(cur_inst.GetOp() < inst_cost.GetSize());
-
+  
   // If first time cost hasn't been paid off...
   if ( inst_ft_cost[cur_inst.GetOp()] > 0 ) {
     inst_ft_cost[cur_inst.GetOp()]--;       // dec cost
     return false;
   }
-    
+  
   // Next, look at the per use cost
-  if ( GetInstSet().GetCost(cur_inst) > 0 ) {
+  if ( m_inst_set->GetCost(cur_inst) > 0 ) {
     if ( inst_cost[cur_inst.GetOp()] > 1 ){  // if isn't paid off (>1)
       inst_cost[cur_inst.GetOp()]--;         // dec cost
       return false;
     } else {                                 // else, reset cost array
-      inst_cost[cur_inst.GetOp()] = GetInstSet().GetCost(cur_inst);
+      inst_cost[cur_inst.GetOp()] = m_inst_set->GetCost(cur_inst);
     }
   }
-    
+  
   // Prob of exec
-  if ( GetInstSet().GetProbFail(cur_inst) > 0.0 ){
-    return !( m_world->GetRandom().P(GetInstSet().GetProbFail(cur_inst)) );
+  if ( m_inst_set->GetProbFail(cur_inst) > 0.0 ){
+    return !( m_world->GetRandom().P(m_inst_set->GetProbFail(cur_inst)) );
   }
 #endif
   return true;
@@ -534,16 +535,16 @@
   
 #ifdef EXECUTION_ERRORS
   // If there is an execution error, execute a random instruction.
-  if (organism->TestExeErr()) actual_inst = GetInstSet().GetRandomInst();
+  if (organism->TestExeErr()) actual_inst = m_inst_set->GetRandomInst();
 #endif /* EXECUTION_ERRORS */
-
+  
   // Get a pointer to the corrisponding method...
-  int inst_idx = GetInstSet().GetLibFunctionIndex(actual_inst);
+  int inst_idx = m_inst_set->GetLibFunctionIndex(actual_inst);
   
   // Mark the instruction as executed
   IP().FlagExecuted() = true;
 	
-
+  
 #ifdef INSTRUCTION_COUNT
   // instruction execution count incremeneted
   organism->GetPhenotype().IncCurInstCount(actual_inst.GetOp());
@@ -558,7 +559,7 @@
     organism->GetPhenotype().DecCurInstCount(actual_inst.GetOp());
   }
 #endif	
-
+  
   return exec_success;
 }
 
@@ -568,65 +569,59 @@
   // Mark this organism as running...
   bool prev_run_state = organism->GetIsRunning();
   organism->SetRunning(true);
-
+  
   // @CAO FIX PRINTING TO INDICATE THIS IS A BONUS
   // Print the status of this CPU at each step...
   if (m_tracer != NULL) {
     if (cHardwareTracer_CPU * tracer
         = dynamic_cast<cHardwareTracer_CPU *>(m_tracer)
-    ){
+        ){
       tracer->TraceHardware_CPUBonus(*this);
     }
   }
-    
+  
   SingleProcess_ExecuteInst(inst);
-
+  
   organism->SetRunning(prev_run_state);
 }
 
 
-void cHardwareCPU::LoadGenome(const cGenome & new_genome)
-{
-  GetMemory() = new_genome;
-}
-
-
 bool cHardwareCPU::OK()
 {
   bool result = true;
-
+  
   if (!memory.OK()) result = false;
-
+  
   for (int i = 0; i < GetNumThreads(); i++) {
     if (threads[i].stack.OK() == false) result = false;
     if (threads[i].next_label.OK() == false) result = false;
   }
-
+  
   return result;
 }
 
 void cHardwareCPU::PrintStatus(ostream& fp)
 {
   fp << organism->GetPhenotype().GetTimeUsed() << " "
-     << "IP:" << IP().GetPosition() << "    "
-
-     << "AX:" << Register(nHardwareCPU::REG_AX) << " "
-     << setbase(16) << "[0x" << Register(nHardwareCPU::REG_AX) << "]  " << setbase(10)
-
-     << "BX:" << Register(nHardwareCPU::REG_BX) << " "
-     << setbase(16) << "[0x" << Register(nHardwareCPU::REG_BX) << "]  " << setbase(10)
-
-     << "CX:" << Register(nHardwareCPU::REG_CX) << " "
-     << setbase(16) << "[0x" << Register(nHardwareCPU::REG_CX) << "]" << setbase(10)
-
-     << endl;
-
+  << "IP:" << IP().GetPosition() << "    "
+  
+  << "AX:" << GetRegister(nHardwareCPU::REG_AX) << " "
+  << setbase(16) << "[0x" << GetRegister(nHardwareCPU::REG_AX) << "]  " << setbase(10)
+  
+  << "BX:" << GetRegister(nHardwareCPU::REG_BX) << " "
+  << setbase(16) << "[0x" << GetRegister(nHardwareCPU::REG_BX) << "]  " << setbase(10)
+  
+  << "CX:" << GetRegister(nHardwareCPU::REG_CX) << " "
+  << setbase(16) << "[0x" << GetRegister(nHardwareCPU::REG_CX) << "]" << setbase(10)
+  
+  << endl;
+  
   fp << "  R-Head:" << GetHead(nHardware::HEAD_READ).GetPosition() << " "
-     << "W-Head:" << GetHead(nHardware::HEAD_WRITE).GetPosition()  << " "
-     << "F-Head:" << GetHead(nHardware::HEAD_FLOW).GetPosition()   << "  "
-     << "RL:" << GetReadLabel().AsString() << "   "
-     << endl;
-
+    << "W-Head:" << GetHead(nHardware::HEAD_WRITE).GetPosition()  << " "
+    << "F-Head:" << GetHead(nHardware::HEAD_FLOW).GetPosition()   << "  "
+    << "RL:" << GetReadLabel().AsString() << "   "
+    << endl;
+  
   fp << "  Mem (" << GetMemory().GetSize() << "):"
 		  << "  " << GetMemory().AsString()
 		  << endl;
@@ -649,30 +644,30 @@
 cHeadCPU cHardwareCPU::FindLabel(int direction)
 {
   cHeadCPU & inst_ptr = IP();
-
+  
   // Start up a search head at the position of the instruction pointer.
   cHeadCPU search_head(inst_ptr);
   cCodeLabel & search_label = GetLabel();
-
+  
   // Make sure the label is of size > 0.
-
+  
   if (search_label.GetSize() == 0) {
     return inst_ptr;
   }
-
+  
   // Call special functions depending on if jump is forwards or backwards.
   int found_pos = 0;
   if( direction < 0 ) {
     found_pos = FindLabel_Backward(search_label, inst_ptr.GetMemory(),
-			   inst_ptr.GetPosition() - search_label.GetSize());
+                                   inst_ptr.GetPosition() - search_label.GetSize());
   }
-
+  
   // Jump forward.
   else if (direction > 0) {
     found_pos = FindLabel_Forward(search_label, inst_ptr.GetMemory(),
-			   inst_ptr.GetPosition());
+                                  inst_ptr.GetPosition());
   }
-
+  
   // Jump forward from the very beginning.
   else {
     found_pos = FindLabel_Forward(search_label, inst_ptr.GetMemory(), 0);
@@ -680,7 +675,7 @@
   
   // Return the last line of the found label, if it was found.
   if (found_pos >= 0) search_head.Set(found_pos - 1);
-
+  
   // Return the found position (still at start point if not found).
   return search_head;
 }
@@ -691,80 +686,80 @@
 // to find search label's match inside another label.
 
 int cHardwareCPU::FindLabel_Forward(const cCodeLabel & search_label,
-				 const cGenome & search_genome, int pos)
+                                    const cGenome & search_genome, int pos)
 {
   assert (pos < search_genome.GetSize() && pos >= 0);
-
+  
   int search_start = pos;
   int label_size = search_label.GetSize();
   bool found_label = false;
-
+  
   // Move off the template we are on.
   pos += label_size;
-
+  
   // Search until we find the complement or exit the memory.
   while (pos < search_genome.GetSize()) {
-
+    
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
-
-    if (inst_set->IsNop(search_genome[pos])) {
+    
+    if (m_inst_set->IsNop(search_genome[pos])) {
       // Find the start and end of the label we're in the middle of.
-
+      
       int start_pos = pos;
       int end_pos = pos + 1;
       while (start_pos > search_start &&
-	     inst_set->IsNop( search_genome[start_pos - 1] )) {
-	start_pos--;
+             m_inst_set->IsNop( search_genome[start_pos - 1] )) {
+        start_pos--;
       }
       while (end_pos < search_genome.GetSize() &&
-	     inst_set->IsNop( search_genome[end_pos] )) {
-	end_pos++;
+             m_inst_set->IsNop( search_genome[end_pos] )) {
+        end_pos++;
       }
       int test_size = end_pos - start_pos;
-
+      
       // See if this label has the proper sub-label within it.
       int max_offset = test_size - label_size + 1;
       int offset = start_pos;
       for (offset = start_pos; offset < start_pos + max_offset; offset++) {
-
-	// Test the number of matches for this offset.
-	int matches;
-	for (matches = 0; matches < label_size; matches++) {
-	  if (search_label[matches] !=
-	      inst_set->GetNopMod( search_genome[offset + matches] )) {
-	    break;
-	  }
-	}
-
-	// If we have found it, break out of this loop!
-	if (matches == label_size) {
-	  found_label = true;
-	  break;
-	}
+        
+        // Test the number of matches for this offset.
+        int matches;
+        for (matches = 0; matches < label_size; matches++) {
+          if (search_label[matches] !=
+              m_inst_set->GetNopMod( search_genome[offset + matches] )) {
+            break;
+          }
+        }
+        
+        // If we have found it, break out of this loop!
+        if (matches == label_size) {
+          found_label = true;
+          break;
+        }
       }
-
+      
       // If we've found the complement label, set the position to the end of
       // the label we found it in, and break out.
-
+      
       if (found_label == true) {
-	// pos = end_pos;
-	pos = label_size + offset;
-	break;
+        // pos = end_pos;
+        pos = label_size + offset;
+        break;
       }
-
+      
       // We haven't found it; jump pos to just after the current label being
       // checked.
       pos = end_pos;
     }
-
+    
     // Jump up a block to the next possible point to find a label,
     pos += label_size;
   }
-
+  
   // If the label was not found return a -1.
   if (found_label == false) pos = -1;
-
+  
   return pos;
 }
 
@@ -773,76 +768,76 @@
 // to find search label's match inside another label.
 
 int cHardwareCPU::FindLabel_Backward(const cCodeLabel & search_label,
-				  const cGenome & search_genome, int pos)
+                                     const cGenome & search_genome, int pos)
 {
   assert (pos < search_genome.GetSize());
-
+  
   int search_start = pos;
   int label_size = search_label.GetSize();
   bool found_label = false;
-
+  
   // Move off the template we are on.
   pos -= label_size;
-
+  
   // Search until we find the complement or exit the memory.
   while (pos >= 0) {
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
-
-    if (inst_set->IsNop( search_genome[pos] )) {
+    
+    if (m_inst_set->IsNop( search_genome[pos] )) {
       // Find the start and end of the label we're in the middle of.
-
+      
       int start_pos = pos;
       int end_pos = pos + 1;
-      while (start_pos > 0 && inst_set->IsNop(search_genome[start_pos - 1])) {
-	start_pos--;
+      while (start_pos > 0 && m_inst_set->IsNop(search_genome[start_pos - 1])) {
+        start_pos--;
       }
       while (end_pos < search_start &&
-	     inst_set->IsNop(search_genome[end_pos])) {
-	end_pos++;
+             m_inst_set->IsNop(search_genome[end_pos])) {
+        end_pos++;
       }
       int test_size = end_pos - start_pos;
-
+      
       // See if this label has the proper sub-label within it.
       int max_offset = test_size - label_size + 1;
       for (int offset = start_pos; offset < start_pos + max_offset; offset++) {
-
-	// Test the number of matches for this offset.
-	int matches;
-	for (matches = 0; matches < label_size; matches++) {
-	  if (search_label[matches] !=
-	      inst_set->GetNopMod(search_genome[offset + matches])) {
-	    break;
-	  }
-	}
-
-	// If we have found it, break out of this loop!
-	if (matches == label_size) {
-	  found_label = true;
-	  break;
-	}
+        
+        // Test the number of matches for this offset.
+        int matches;
+        for (matches = 0; matches < label_size; matches++) {
+          if (search_label[matches] !=
+              m_inst_set->GetNopMod(search_genome[offset + matches])) {
+            break;
+          }
+        }
+        
+        // If we have found it, break out of this loop!
+        if (matches == label_size) {
+          found_label = true;
+          break;
+        }
       }
-
+      
       // If we've found the complement label, set the position to the end of
       // the label we found it in, and break out.
-
+      
       if (found_label == true) {
-	pos = end_pos;
-	break;
+        pos = end_pos;
+        break;
       }
-
+      
       // We haven't found it; jump pos to just before the current label
       // being checked.
       pos = start_pos - 1;
     }
-
+    
     // Jump up a block to the next possible point to find a label,
     pos -= label_size;
   }
-
+  
   // If the label was not found return a -1.
   if (found_label == false) pos = -1;
-
+  
   return pos;
 }
 
@@ -850,35 +845,35 @@
 cHeadCPU cHardwareCPU::FindLabel(const cCodeLabel & in_label, int direction)
 {
   assert (in_label.GetSize() > 0);
-
+  
   // IDEALY:
   // Keep making jumps (in the proper direction) equal to the label
   // length.  If we are inside of a label, check its size, and see if
   // any of the sub-labels match properly.
   // FOR NOW:
   // Get something which works, no matter how inefficient!!!
-
+  
   cHeadCPU temp_head(this);
-
+  
   while (temp_head.InMemory()) {
     // IDEALY: Analyze the label we are in; see if the one we are looking
     // for could be a sub-label of it.  Skip past it if not.
-
+    
     int i;
     for (i = 0; i < in_label.GetSize(); i++) {
-      if (!inst_set->IsNop(temp_head.GetInst()) ||
-	  in_label[i] != inst_set->GetNopMod(temp_head.GetInst())) {
-	break;
+      if (!m_inst_set->IsNop(temp_head.GetInst()) ||
+          in_label[i] != m_inst_set->GetNopMod(temp_head.GetInst())) {
+        break;
       }
     }
     if (i == GetLabel().GetSize()) {
       temp_head.AbsJump(i - 1);
       return temp_head;
     }
-
+    
     temp_head.AbsJump(direction);     // IDEALY: MAKE LARGER JUMPS
   }
-
+  
   temp_head.AbsSet(-1);
   return temp_head;
 }
@@ -889,64 +884,64 @@
 {
   // cout << "Running FindFullLabel with " << in_label.AsString() <<
   // endl;
-
+  
   assert(in_label.GetSize() > 0); // Trying to find label of 0 size!
-
+  
   cHeadCPU temp_head(this);
-
+  
   while (temp_head.InMemory()) {
     // If we are not in a label, jump to the next checkpoint...
-    if (inst_set->IsNop(temp_head.GetInst())) {
+    if (m_inst_set->IsNop(temp_head.GetInst())) {
       temp_head.AbsJump(in_label.GetSize());
       continue;
     }
-
+    
     // Otherwise, rewind to the begining of this label...
-
-    while (!(temp_head.AtFront()) && inst_set->IsNop(temp_head.GetInst(-1)))
+    
+    while (!(temp_head.AtFront()) && m_inst_set->IsNop(temp_head.GetInst(-1)))
       temp_head.AbsJump(-1);
-
+    
     // Calculate the size of the label being checked, and make sure they
     // are equal.
-
+    
     int checked_size = 0;
-    while (inst_set->IsNop(temp_head.GetInst(checked_size))) {
+    while (m_inst_set->IsNop(temp_head.GetInst(checked_size))) {
       checked_size++;
     }
     if (checked_size != in_label.GetSize()) {
       temp_head.AbsJump(checked_size + 1);
       continue;
     }
-
+    
     // cout << "Testing label at line " << temp_head.GetPosition() <<
     // endl;
-
+    
     // ...and do the comparison...
-
+    
     int j;
     bool label_match = true;
     for (j = 0; j < in_label.GetSize(); j++) {
-      if (!inst_set->IsNop(temp_head.GetInst(j)) ||
-	  in_label[j] != inst_set->GetNopMod(temp_head.GetInst(j))) {
-	temp_head.AbsJump(in_label.GetSize() + 1);
-	label_match = false;
-	break;
+      if (!m_inst_set->IsNop(temp_head.GetInst(j)) ||
+          in_label[j] != m_inst_set->GetNopMod(temp_head.GetInst(j))) {
+        temp_head.AbsJump(in_label.GetSize() + 1);
+        label_match = false;
+        break;
       }
     }
-
+    
     if (label_match) {
       // If we have found the label, return the position after it.
       temp_head.AbsJump(j - 1);
       return temp_head;
     }
-
+    
     // We have not found the label... increment i.
-
+    
     temp_head.AbsJump(in_label.GetSize() + 1);
   }
-
+  
   // The label does not exist in this creature.
-
+  
   temp_head.AbsSet(-1);
   return temp_head;
 }
@@ -955,36 +950,36 @@
 bool cHardwareCPU::InjectHost(const cCodeLabel & in_label, const cGenome & injection)
 {
   // Make sure the genome will be below max size after injection.
-
+  
   const int new_size = injection.GetSize() + GetMemory().GetSize();
   if (new_size > MAX_CREATURE_SIZE) return false; // (inject fails)
-
+  
   const int inject_line = FindFullLabel(in_label).GetPosition();
-
+  
   // Abort if no compliment is found.
   if (inject_line == -1) return false; // (inject fails)
-
+  
   // Inject the code!
   InjectCode(injection, inject_line+1);
-
+  
   return true; // (inject succeeds!)
 }
 
 int cHardwareCPU::InjectThread(const cCodeLabel & in_label, const cGenome & injection)
 {
   // Make sure the genome will be below max size after injection.
-
+  
   const int new_size = injection.GetSize() + GetMemory().GetSize();
   if (new_size > MAX_CREATURE_SIZE) return 1; // (inject fails)
-
+  
   const int inject_line = FindFullLabel(in_label).GetPosition();
-
+  
   // Abort if no compliment is found.
   if (inject_line == -1) return 2; // (inject fails)
-
+  
   // Inject the code!
   InjectCodeThread(injection, inject_line+1);
-
+  
   return 0; // (inject succeeds!)
 }
 
@@ -993,7 +988,7 @@
   assert(line_num >= 0);
   assert(line_num <= memory.GetSize());
   assert(memory.GetSize() + inject_code.GetSize() < MAX_CREATURE_SIZE);
-
+  
   // Inject the new code.
   const int inject_size = inject_code.GetSize();
   memory.Insert(line_num, inject_code);
@@ -1003,12 +998,12 @@
     memory.FlagInjected(i) = true;
   }
   organism->GetPhenotype().IsModified() = true;
-
+  
   // Adjust all of the heads to take into account the new mem size.
-
+  
   for (int i=0; i < nHardware::NUM_HEADS; i++) {    
     if (!GetHead(i).TestParasite() &&
-	GetHead(i).GetPosition() > line_num)
+        GetHead(i).GetPosition() > line_num)
       GetHead(i).Jump(inject_size);
   }
 }
@@ -1020,47 +1015,47 @@
   assert(memory.GetSize() + inject_code.GetSize() < MAX_CREATURE_SIZE);
   
   if(ForkThread())
+  {
+    // Inject the new code.
+    const int inject_size = inject_code.GetSize();
+    memory.Insert(line_num, inject_code);
+    
+    // Set instruction flags on the injected code
+    for (int i = line_num; i < line_num + inject_size; i++) {
+      memory.FlagInjected(i) = true;
+    }
+    organism->GetPhenotype().IsModified() = true;
+    organism->GetPhenotype().IsMultiThread() = true;
+    
+    // Adjust all of the heads to take into account the new mem size.
+    
+    int currthread = GetCurThread();
+    SetThread(0);
+    for (int i=0; i<GetNumThreads()-2; i++)
     {
-      // Inject the new code.
-      const int inject_size = inject_code.GetSize();
-      memory.Insert(line_num, inject_code);
-      
-      // Set instruction flags on the injected code
-      for (int i = line_num; i < line_num + inject_size; i++) {
-	memory.FlagInjected(i) = true;
-      }
-      organism->GetPhenotype().IsModified() = true;
-      organism->GetPhenotype().IsMultiThread() = true;
-      
-      // Adjust all of the heads to take into account the new mem size.
-      
-      int currthread = GetCurThread();
-      SetThread(0);
-      for (int i=0; i<GetNumThreads()-2; i++)
-	{
-	  for (int j=0; j < nHardware::NUM_HEADS; j++) 
+      for (int j=0; j < nHardware::NUM_HEADS; j++) 
 	    {    
 	      if (!GetHead(i).TestParasite() && GetHead(i).GetPosition() > line_num)
-		GetHead(i).Jump(inject_size);
+          GetHead(i).Jump(inject_size);
 	    }
-	  NextThread();
-	}
-      SetThread(currthread);
-          
+      NextThread();
     }
+    SetThread(currthread);
+    
+  }
   else
-    {
-      //Some kind of error message should go here...but what?
-    }
-
+  {
+    //Some kind of error message should go here...but what?
+  }
+  
 }
 
 void cHardwareCPU::Mutate(int mut_point)
 {
   // Test if trying to mutate outside of genome...
   assert(mut_point >= 0 && mut_point < GetMemory().GetSize());
-
-  GetMemory()[mut_point] = GetRandomInst();
+  
+  GetMemory()[mut_point] = m_inst_set->GetRandomInst();
   GetMemory().FlagMutated(mut_point) = true;
   GetMemory().FlagPointMut(mut_point) = true;
   //organism->GetPhenotype().IsMutated() = true;
@@ -1070,13 +1065,13 @@
 int cHardwareCPU::PointMutate(const double mut_rate)
 {
   const int num_muts =
-    m_world->GetRandom().GetRandBinomial(GetMemory().GetSize(), mut_rate);
-
+  m_world->GetRandom().GetRandBinomial(GetMemory().GetSize(), mut_rate);
+  
   for (int i = 0; i < num_muts; i++) {
     const int pos = m_world->GetRandom().GetUInt(GetMemory().GetSize());
     Mutate(pos);
   }
-
+  
   return num_muts;
 }
 
@@ -1088,10 +1083,10 @@
 {
   // Only update triggers should happen from the outside!
   assert(trigger == nMutation::TRIGGER_UPDATE);
-
+  
   // Assume instruction pointer is the intended target (if one is even
   // needed!
-
+  
   return TriggerMutations(trigger, IP());
 }
 
@@ -1101,54 +1096,54 @@
   cLocalMutations & mut_info = organism->GetLocalMutations();
   const tList<cMutation> & mut_list =
     mut_info.GetMutationLib().GetMutationList(trigger);
-
+  
   // If we have no mutations for this trigger, stop here.
   if (mut_list.GetSize() == 0) return false;
   bool has_mutation = false;
-
+  
   // Determine what memory this mutation will be affecting.
   cCPUMemory & target_mem = (trigger == nMutation::TRIGGER_DIVIDE) 
     ? organism->ChildGenome() : GetMemory();
-
+  
   // Loop through all mutations associated with this trigger and test them.
   tConstListIterator<cMutation> mut_it(mut_list);
-
+  
   while (mut_it.Next() != NULL) {
     const cMutation * cur_mut = mut_it.Get();
     const int mut_id = cur_mut->GetID();
     const int scope = cur_mut->GetScope();
     const double rate = mut_info.GetRate(mut_id);
     switch (scope) {
-    case nMutation::SCOPE_GENOME:
-      if (TriggerMutations_ScopeGenome(cur_mut, target_mem, cur_head, rate)) {
-	has_mutation = true;
-	mut_info.IncCount(mut_id);
-      }
-      break;
-    case nMutation::SCOPE_LOCAL:
-    case nMutation::SCOPE_PROP:
-      if (TriggerMutations_ScopeLocal(cur_mut, target_mem, cur_head, rate)) {
-	has_mutation = true;
-	mut_info.IncCount(mut_id);
-      }
-      break;
-    case nMutation::SCOPE_GLOBAL:
-    case nMutation::SCOPE_SPREAD:
-      int num_muts =
-	TriggerMutations_ScopeGlobal(cur_mut, target_mem, cur_head, rate);
-      if (num_muts > 0) {
-	has_mutation = true;
-	mut_info.IncCount(mut_id, num_muts);
-      }
-      break;
+      case nMutation::SCOPE_GENOME:
+        if (TriggerMutations_ScopeGenome(cur_mut, target_mem, cur_head, rate)) {
+          has_mutation = true;
+          mut_info.IncCount(mut_id);
+        }
+        break;
+      case nMutation::SCOPE_LOCAL:
+      case nMutation::SCOPE_PROP:
+        if (TriggerMutations_ScopeLocal(cur_mut, target_mem, cur_head, rate)) {
+          has_mutation = true;
+          mut_info.IncCount(mut_id);
+        }
+        break;
+      case nMutation::SCOPE_GLOBAL:
+      case nMutation::SCOPE_SPREAD:
+        int num_muts =
+        TriggerMutations_ScopeGlobal(cur_mut, target_mem, cur_head, rate);
+        if (num_muts > 0) {
+          has_mutation = true;
+          mut_info.IncCount(mut_id, num_muts);
+        }
+          break;
     }
   }
-
+  
   return has_mutation;
 }
 
 bool cHardwareCPU::TriggerMutations_ScopeGenome(const cMutation * cur_mut,
-          cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate)
+                                                cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate)
 {
   // The rate we have stored indicates the probability that a single
   // mutation will occur anywhere in the genome.
@@ -1165,11 +1160,11 @@
 }
 
 bool cHardwareCPU::TriggerMutations_ScopeLocal(const cMutation * cur_mut,
-          cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate)
+                                               cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate)
 {
   // The rate we have stored is the probability for a mutation at this single
   // position in the genome.
-
+  
   if (m_world->GetRandom().P(rate) == true) {
     TriggerMutations_Body(cur_mut->GetType(), target_memory, cur_head);
     return true;
@@ -1178,15 +1173,15 @@
 }
 
 int cHardwareCPU::TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
-          cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate)
+                                               cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate)
 {
   // The probability we have stored is per-site, so we can pull a random
   // number from a binomial distribution to determine the number of mutations
   // that should occur.
-
+  
   const int num_mut =
-    m_world->GetRandom().GetRandBinomial(target_memory.GetSize(), rate);
-
+  m_world->GetRandom().GetRandBinomial(target_memory.GetSize(), rate);
+  
   if (num_mut > 0) {
     for (int i = 0; i < num_mut; i++) {
       cHeadCPU tmp_head(cur_head);
@@ -1194,35 +1189,35 @@
       TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
     }
   }
-
+  
   return num_mut;
 }
 
 void cHardwareCPU::TriggerMutations_Body(int type, cCPUMemory & target_memory,
-					 cHeadCPU & cur_head)
+                                         cHeadCPU & cur_head)
 {
   const int pos = cur_head.GetPosition();
-
+  
   switch (type) {
-  case nMutation::TYPE_POINT:
-    target_memory[pos] = GetRandomInst();
-    target_memory.FlagMutated(pos) = true;
-    break;
-  case nMutation::TYPE_INSERT:
-  case nMutation::TYPE_DELETE:
-  case nMutation::TYPE_HEAD_INC:
-  case nMutation::TYPE_HEAD_DEC:
-  case nMutation::TYPE_TEMP:
-  case nMutation::TYPE_KILL:
-  default:
-    cout << "Error: Mutation type not implemented!" << endl;
-    break;
+    case nMutation::TYPE_POINT:
+      target_memory[pos] = m_inst_set->GetRandomInst();
+      target_memory.FlagMutated(pos) = true;
+      break;
+    case nMutation::TYPE_INSERT:
+    case nMutation::TYPE_DELETE:
+    case nMutation::TYPE_HEAD_INC:
+    case nMutation::TYPE_HEAD_DEC:
+    case nMutation::TYPE_TEMP:
+    case nMutation::TYPE_KILL:
+    default:
+      cout << "Error: Mutation type not implemented!" << endl;
+      break;
   };
 }
 
 void cHardwareCPU::ReadInst(const int in_inst)
 {
-  if (inst_set->IsNop( cInstruction(in_inst) )) {
+  if (m_inst_set->IsNop( cInstruction(in_inst) )) {
     GetReadLabel().AddNop(in_inst);
   } else {
     GetReadLabel().Clear();
@@ -1249,15 +1244,15 @@
 {
   int count = 0;
   cHeadCPU * inst_ptr = &( IP() );
-
+  
   GetLabel().Clear();
-
-  while (inst_set->IsNop(inst_ptr->GetNextInst()) &&
-	 (count < max_size)) {
+  
+  while (m_inst_set->IsNop(inst_ptr->GetNextInst()) &&
+         (count < max_size)) {
     count++;
     inst_ptr->Advance();
-    GetLabel().AddNop(inst_set->GetNopMod(inst_ptr->GetInst()));
-
+    GetLabel().AddNop(m_inst_set->GetNopMod(inst_ptr->GetInst()));
+    
     // If this is the first line of the template, mark it executed.
     if (GetLabel().GetSize() <=	m_world->GetConfig().MAX_LABEL_EXE_SIZE.Get()) {
       inst_ptr->FlagExecuted() = true;
@@ -1270,20 +1265,20 @@
 {
   const int num_threads = GetNumThreads();
   if (num_threads == m_world->GetConfig().MAX_CPU_THREADS.Get()) return false;
-
+  
   // Make room for the new thread.
   threads.Resize(num_threads + 1);
-
+  
   // Initialize the new thread to the same values as the current one.
   threads[num_threads] = threads[cur_thread];
-
+  
   // Find the first free bit in thread_id_chart to determine the new
   // thread id.
   int new_id = 0;
   while ( (thread_id_chart >> new_id) & 1 == 1) new_id++;
   threads[num_threads].SetID(new_id);
   thread_id_chart |= (1 << new_id);
-
+  
   return true;
 }
 
@@ -1298,25 +1293,25 @@
 {
   // Make sure that there is always at least one thread...
   if (GetNumThreads() == 1) return false;
-
+  
   // Note the current thread and set the current back one.
   const int kill_thread = cur_thread;
   PrevThread();
   
   // Turn off this bit in the thread_id_chart...
   thread_id_chart ^= 1 << threads[kill_thread].GetID();
-
+  
   // Copy the last thread into the kill position
   const int last_thread = GetNumThreads() - 1;
   if (last_thread != kill_thread) {
     threads[kill_thread] = threads[last_thread];
   }
-
+  
   // Kill the thread!
   threads.Resize(GetNumThreads() - 1);
-
+  
   if (cur_thread > kill_thread) cur_thread--;
-
+  
   return true;
 }
 
@@ -1327,10 +1322,10 @@
 inline int cHardwareCPU::FindModifiedRegister(int default_register)
 {
   assert(default_register < nHardwareCPU::NUM_REGISTERS);  // Reg ID too high.
-
-  if (GetInstSet().IsNop(IP().GetNextInst())) {
+  
+  if (m_inst_set->IsNop(IP().GetNextInst())) {
     IP().Advance();
-    default_register = GetInstSet().GetNopMod(IP().GetInst());
+    default_register = m_inst_set->GetNopMod(IP().GetInst());
     IP().FlagExecuted() = true;
   }
   return default_register;
@@ -1340,10 +1335,10 @@
 inline int cHardwareCPU::FindModifiedHead(int default_head)
 {
   assert(default_head < nHardware::NUM_HEADS); // Head ID too high.
-
-  if (GetInstSet().IsNop(IP().GetNextInst())) {
+  
+  if (m_inst_set->IsNop(IP().GetNextInst())) {
     IP().Advance();
-    default_head = GetInstSet().GetNopMod(IP().GetInst());
+    default_head = m_inst_set->GetNopMod(IP().GetInst());
     IP().FlagExecuted() = true;
   }
   return default_head;
@@ -1372,9 +1367,9 @@
 bool cHardwareCPU::Allocate_Random(const int old_size, const int new_size)
 {
   GetMemory().Resize(new_size);
-
+  
   for (int i = old_size; i < new_size; i++) {
-    GetMemory()[i] = GetInstSet().GetRandomInst();
+    GetMemory()[i] = m_inst_set->GetRandomInst();
   }
   return true;
 }
@@ -1382,9 +1377,9 @@
 bool cHardwareCPU::Allocate_Default(const int new_size)
 {
   GetMemory().Resize(new_size);
-
+  
   // New space already defaults to default instruction...
-
+  
   return true;
 }
 
@@ -1397,70 +1392,70 @@
   }
   if (allocated_size < 1) {
     Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Allocate of %d too small", allocated_size));
+          cStringUtil::Stringf("Allocate of %d too small", allocated_size));
     return false;
   }
-
+  
   const int old_size = GetMemory().GetSize();
   const int new_size = old_size + allocated_size;
-
+  
   // Make sure that the new size is in range.
   if (new_size > MAX_CREATURE_SIZE  ||  new_size < MIN_CREATURE_SIZE) {
     Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Invalid post-allocate size (%d)",
-			       new_size));
+          cStringUtil::Stringf("Invalid post-allocate size (%d)",
+                               new_size));
     return false;
   }
-
+  
   const int max_alloc_size = (int) (old_size * m_world->GetConfig().CHILD_SIZE_RANGE.Get());
   if (allocated_size > max_alloc_size) {
     Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Allocate too large (%d > %d)",
-			       allocated_size, max_alloc_size));
+          cStringUtil::Stringf("Allocate too large (%d > %d)",
+                               allocated_size, max_alloc_size));
     return false;
   }
-
+  
   const int max_old_size =
     (int) (allocated_size * m_world->GetConfig().CHILD_SIZE_RANGE.Get());
   if (old_size > max_old_size) {
     Fault(FAULT_LOC_ALLOC, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Allocate too small (%d > %d)",
-			       old_size, max_old_size));
+          cStringUtil::Stringf("Allocate too small (%d > %d)",
+                               old_size, max_old_size));
     return false;
   }
-
+  
   switch (m_world->GetConfig().ALLOC_METHOD.Get()) {
-  case ALLOC_METHOD_NECRO:
-    // Only break if this succeeds -- otherwise just do random.
-    if (Allocate_Necro(new_size) == true) break;
-  case ALLOC_METHOD_RANDOM:
-    Allocate_Random(old_size, new_size);
-    break;
-  case ALLOC_METHOD_DEFAULT:
-    Allocate_Default(new_size);
-    break;
+    case ALLOC_METHOD_NECRO:
+      // Only break if this succeeds -- otherwise just do random.
+      if (Allocate_Necro(new_size) == true) break;
+    case ALLOC_METHOD_RANDOM:
+      Allocate_Random(old_size, new_size);
+      break;
+    case ALLOC_METHOD_DEFAULT:
+      Allocate_Default(new_size);
+      break;
   }
-
+  
   mal_active = true;
-
+  
   return true;
 }
 
 
 bool cHardwareCPU::Divide_CheckViable(const int child_size,
-				      const int parent_size)
+                                      const int parent_size)
 {
   // Make sure the organism is okay with dividing now...
   if (organism->Divide_CheckViable() == false) return false; // (divide fails)
-
+  
   // If required, make sure an allocate has occured.
   if (m_world->GetConfig().REQUIRE_ALLOCATE.Get() && mal_active == false) {
     Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR, "Must allocate before divide");
     return false; //  (divide fails)
   }
-
+  
   // Make sure that neither parent nor child will be below the minimum size.
-
+  
   const int genome_size = organism->GetGenome().GetSize();
   const double size_range = m_world->GetConfig().CHILD_SIZE_RANGE.Get();
   const int min_size = Max(MIN_CREATURE_SIZE, (int) (genome_size/size_range));
@@ -1468,52 +1463,52 @@
   
   if (child_size < min_size || child_size > max_size) {
     Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Invalid offspring length (%d)", child_size));
+          cStringUtil::Stringf("Invalid offspring length (%d)", child_size));
     return false; // (divide fails)
   }
   if (parent_size < min_size || parent_size > max_size) {
     Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Invalid post-divide length (%d)",parent_size));
+          cStringUtil::Stringf("Invalid post-divide length (%d)",parent_size));
     return false; // (divide fails)
   }
-
+  
   // Count the number of lines executed in the parent, and make sure the
   // specified fraction has been reached.
-
+  
   int executed_size = 0;
   for (int i = 0; i < parent_size; i++) {
     if (GetMemory().FlagExecuted(i)) executed_size++;
   }
-
+  
   const int min_exe_lines = (int) (parent_size * m_world->GetConfig().MIN_EXE_LINES.Get());
   if (executed_size < min_exe_lines) {
     Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Too few executed lines (%d < %d)",
-			       executed_size, min_exe_lines));
+          cStringUtil::Stringf("Too few executed lines (%d < %d)",
+                               executed_size, min_exe_lines));
     return false; // (divide fails)
   }
 	
   // Count the number of lines which were copied into the child, and make
   // sure the specified fraction has been reached.
-
+  
   int copied_size = 0;
   for (int i = parent_size; i < parent_size + child_size; i++) {
     if (GetMemory().FlagCopied(i)) copied_size++;
   }
-
+  
   const int min_copied =  (int) (child_size * m_world->GetConfig().MIN_COPIED_LINES.Get());
   if (copied_size < min_copied) {
     Fault(FAULT_LOC_DIVIDE, FAULT_TYPE_ERROR,
-	  cStringUtil::Stringf("Too few copied commands (%d < %d)",
-			       copied_size, min_copied));
+          cStringUtil::Stringf("Too few copied commands (%d < %d)",
+                               copied_size, min_copied));
     return false; // (divide fails)
   }
-
+  
   // Save the information we collected here...
   cPhenotype & phenotype = organism->GetPhenotype();
   phenotype.SetLinesExecuted(executed_size);
   phenotype.SetLinesCopied(copied_size);
-
+  
   // Determine the fitness of this organism as compared to its parent...
   if (m_world->GetTestSterilize() == true &&
       phenotype.IsInjected() == false) {
@@ -1521,13 +1516,13 @@
     const double cur_fitness =
       merit_base * phenotype.GetCurBonus() / phenotype.GetTimeUsed();
     const double fitness_ratio = cur_fitness / phenotype.GetLastFitness();
-
-
+    
+    
     //  const double neut_min = parent_fitness * nHardware::FITNESS_NEUTRAL_MIN;
     //  const double neut_max = parent_fitness * nHardware::FITNESS_NEUTRAL_MAX;
-  
+    
     bool sterilize = false;
-  
+    
     if (fitness_ratio < nHardware::FITNESS_NEUTRAL_MIN) {
       if (m_world->GetRandom().P(organism->GetSterilizeNeg())) sterilize = true;
     } else if (fitness_ratio <= nHardware::FITNESS_NEUTRAL_MAX) {
@@ -1535,22 +1530,22 @@
     } else {
       if (m_world->GetRandom().P(organism->GetSterilizePos())) sterilize = true;
     }
-  
-//     cout << "[ min(" << genome_size
-// 	 << "," << copied_size
-// 	 << "," << executed_size
-// 	 << ") * " << phenotype.GetCurBonus()
-// 	 << " / " << phenotype.GetTimeUsed()
-// 	 << "] / " << phenotype.GetLastFitness()
-// 	 << " == " << fitness_ratio;
-
+    
+    //     cout << "[ min(" << genome_size
+    // 	 << "," << copied_size
+    // 	 << "," << executed_size
+    // 	 << ") * " << phenotype.GetCurBonus()
+    // 	 << " / " << phenotype.GetTimeUsed()
+    // 	 << "] / " << phenotype.GetLastFitness()
+    // 	 << " == " << fitness_ratio;
+    
     if (sterilize == true) {
       //Don't let this organism have this or any more children!
       phenotype.IsFertile() = false;
       return false;
     }    
   }
-
+  
   return true; // (divide succeeds!)
 }
 
@@ -1561,21 +1556,21 @@
   cCPUMemory & child_genome = organism->ChildGenome();
   
   organism->GetPhenotype().SetDivType(mut_multiplier);
-
+  
   // Divide Mutations
   if (organism->TestDivideMut()) {
     const UINT mut_line = m_world->GetRandom().GetUInt(child_genome.GetSize());
-    child_genome[mut_line] = GetRandomInst();
+    child_genome[mut_line] = m_inst_set->GetRandomInst();
     cpu_stats.mut_stats.divide_mut_count++;
   }
-
+  
   // Divide Insertions
   if (organism->TestDivideIns() && child_genome.GetSize() < MAX_CREATURE_SIZE){
     const UINT mut_line = m_world->GetRandom().GetUInt(child_genome.GetSize() + 1);
-    child_genome.Insert(mut_line, GetRandomInst());
+    child_genome.Insert(mut_line, m_inst_set->GetRandomInst());
     cpu_stats.mut_stats.divide_insert_mut_count++;
   }
-
+  
   // Divide Deletions
   if (organism->TestDivideDel() && child_genome.GetSize() > MIN_CREATURE_SIZE){
     const UINT mut_line = m_world->GetRandom().GetUInt(child_genome.GetSize());
@@ -1583,26 +1578,26 @@
     child_genome.Remove(mut_line);
     cpu_stats.mut_stats.divide_delete_mut_count++;
   }
-
+  
   // Divide Mutations (per site)
   if(organism->GetDivMutProb() > 0){
     int num_mut = m_world->GetRandom().GetRandBinomial(child_genome.GetSize(), 
-				   	   organism->GetDivMutProb() / mut_multiplier);
+                                                       organism->GetDivMutProb() / mut_multiplier);
     // If we have lines to mutate...
     if( num_mut > 0 ){
       for (int i = 0; i < num_mut; i++) {
-	int site = m_world->GetRandom().GetUInt(child_genome.GetSize());
-	child_genome[site]=GetRandomInst();
-	cpu_stats.mut_stats.div_mut_count++;
+        int site = m_world->GetRandom().GetUInt(child_genome.GetSize());
+        child_genome[site] = m_inst_set->GetRandomInst();
+        cpu_stats.mut_stats.div_mut_count++;
       }
     }
   }
-
-
+  
+  
   // Insert Mutations (per site)
   if(organism->GetInsMutProb() > 0){
     int num_mut = m_world->GetRandom().GetRandBinomial(child_genome.GetSize(),
-					   organism->GetInsMutProb());
+                                                       organism->GetInsMutProb());
     // If would make creature to big, insert up to MAX_CREATURE_SIZE
     if( num_mut + child_genome.GetSize() > MAX_CREATURE_SIZE ){
       num_mut = MAX_CREATURE_SIZE - child_genome.GetSize();
@@ -1612,28 +1607,28 @@
       // Build a list of the sites where mutations occured
       static int mut_sites[MAX_CREATURE_SIZE];
       for (int i = 0; i < num_mut; i++) {
-	mut_sites[i] = m_world->GetRandom().GetUInt(child_genome.GetSize() + 1);
+        mut_sites[i] = m_world->GetRandom().GetUInt(child_genome.GetSize() + 1);
       }
       // Sort the list
       qsort( (void*)mut_sites, num_mut, sizeof(int), &IntCompareFunction );
       // Actually do the mutations (in reverse sort order)
       for(int i = num_mut-1; i >= 0; i--) {
-	child_genome.Insert(mut_sites[i], GetRandomInst());
-	cpu_stats.mut_stats.insert_mut_count++;
+        child_genome.Insert(mut_sites[i], m_inst_set->GetRandomInst());
+        cpu_stats.mut_stats.insert_mut_count++;
       }
     }
   }
-
-
+  
+  
   // Delete Mutations (per site)
   if( organism->GetDelMutProb() > 0 ){
     int num_mut = m_world->GetRandom().GetRandBinomial(child_genome.GetSize(),
-					   organism->GetDelMutProb());
+                                                       organism->GetDelMutProb());
     // If would make creature too small, delete down to MIN_CREATURE_SIZE
     if (child_genome.GetSize() - num_mut < MIN_CREATURE_SIZE) {
       num_mut = child_genome.GetSize() - MIN_CREATURE_SIZE;
     }
-
+    
     // If we have lines to delete...
     for (int i = 0; i < num_mut; i++) {
       int site = m_world->GetRandom().GetUInt(child_genome.GetSize());
@@ -1642,18 +1637,18 @@
       cpu_stats.mut_stats.delete_mut_count++;
     }
   }
-
+  
   // Mutations in the parent's genome
   if (organism->GetParentMutProb() > 0) {
     for (int i = 0; i < GetMemory().GetSize(); i++) {
       if (organism->TestParentMut()) {
-	GetMemory()[i] = GetRandomInst();
-	cpu_stats.mut_stats.parent_mut_line_count++;
+        GetMemory()[i] = m_inst_set->GetRandomInst();
+        cpu_stats.mut_stats.parent_mut_line_count++;
       }
     }
   }
-
-
+  
+  
   // Count up mutated lines
   for(int i = 0; i < GetMemory().GetSize(); i++){
     if (GetMemory().FlagPointMut(i) == true) {
@@ -1674,16 +1669,16 @@
   cPhenotype & phenotype = organism->GetPhenotype();
   phenotype.CopyTrue() = ( organism->ChildGenome() == organism->GetGenome() );
   phenotype.ChildFertile() = true;
-
+  
   // Only continue if we're supposed to do a fitness test on divide...
   if (organism->GetTestOnDivide() == false) return;
-
+  
   // If this was a perfect copy, then we don't need to worry about any other
   // tests...  Theoretically, we need to worry about the parent changing,
   // but as long as the child is always compared to the original genotype,
   // this won't be an issue.
   if (phenotype.CopyTrue() == true) return;
-
+  
   const double parent_fitness = organism->GetTestFitness();
   const double neut_min = parent_fitness * nHardware::FITNESS_NEUTRAL_MIN;
   const double neut_max = parent_fitness * nHardware::FITNESS_NEUTRAL_MAX;
@@ -1721,7 +1716,7 @@
   if (revert == true) {
     organism->ChildGenome() = organism->GetGenome();
   }
-
+  
   if (sterilize == true) {
     organism->GetPhenotype().ChildFertile() = false;
   }
@@ -1731,46 +1726,46 @@
 bool cHardwareCPU::Divide_Main(const int div_point, const int extra_lines, double mut_multiplier)
 {
   const int child_size = GetMemory().GetSize() - div_point - extra_lines;
-
+  
   // Make sure this divide will produce a viable offspring.
   const bool viable = Divide_CheckViable(child_size, div_point);
   if (viable == false) return false;
-
+  
   // Since the divide will now succeed, set up the information to be sent
   // to the new organism
   cGenome & child_genome = organism->ChildGenome();
   child_genome = cGenomeUtil::Crop(memory, div_point, div_point+child_size);
-
+  
   // Cut off everything in this memory past the divide point.
   GetMemory().Resize(div_point);
-
+  
   // Handle Divide Mutations...
   Divide_DoMutations(mut_multiplier);
-
+  
   // Many tests will require us to run the offspring through a test CPU;
   // this is, for example, to see if mutations need to be reverted or if
   // lineages need to be updated.
   Divide_TestFitnessMeasures();
-
+  
 #ifdef INSTRUCTION_COSTS
   // reset first time instruction costs
   for (int i = 0; i < inst_ft_cost.GetSize(); i++) {
-    inst_ft_cost[i] = GetInstSet().GetFTCost(cInstruction(i));
+    inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
   }
 #endif
-
+  
   mal_active = false;
   if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) {
     advance_ip = false;
   }
-
+  
   // Activate the child, and do more work if the parent lives through the
   // birth.
   bool parent_alive = organism->ActivateDivide();
   if (parent_alive) {
     if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) Reset();
   }
-
+  
   return true;
 }
 
@@ -1782,14 +1777,14 @@
 bool cHardwareCPU::Inst_If0()          // Execute next if ?bx? ==0.
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  if (Register(reg_used) != 0)  IP().Advance();
+  if (GetRegister(reg_used) != 0)  IP().Advance();
   return true; 
 }
 
 bool cHardwareCPU::Inst_IfNot0()       // Execute next if ?bx? != 0.
 { 
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  if (Register(reg_used) == 0)  IP().Advance();
+  if (GetRegister(reg_used) == 0)  IP().Advance();
   return true;
 }
 
@@ -1797,7 +1792,7 @@
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
   const int reg_used2 = FindComplementRegister(reg_used);
-  if (Register(reg_used) != Register(reg_used2))  IP().Advance();
+  if (GetRegister(reg_used) != GetRegister(reg_used2))  IP().Advance();
   return true;
 }
 
@@ -1805,14 +1800,14 @@
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
   const int reg_used2 = FindComplementRegister(reg_used);
-  if (Register(reg_used) == Register(reg_used2))  IP().Advance();
+  if (GetRegister(reg_used) == GetRegister(reg_used2))  IP().Advance();
   return true;
 }
 
 bool cHardwareCPU::Inst_IfGr0()       // Execute next if ?bx? ! < 0.
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  if (Register(reg_used) <= 0)  IP().Advance();
+  if (GetRegister(reg_used) <= 0)  IP().Advance();
   return true;
 }
 
@@ -1820,14 +1815,14 @@
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
   const int reg_used2 = FindComplementRegister(reg_used);
-  if (Register(reg_used) <= Register(reg_used2))  IP().Advance();
+  if (GetRegister(reg_used) <= GetRegister(reg_used2))  IP().Advance();
   return true;
 }
 
 bool cHardwareCPU::Inst_IfGrEqu0()       // Execute next if ?bx? != 0.
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  if (Register(reg_used) < 0)  IP().Advance();
+  if (GetRegister(reg_used) < 0)  IP().Advance();
   return true;
 }
 
@@ -1835,14 +1830,14 @@
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
   const int reg_used2 = FindComplementRegister(reg_used);
-  if (Register(reg_used) < Register(reg_used2)) IP().Advance();
+  if (GetRegister(reg_used) < GetRegister(reg_used2)) IP().Advance();
   return true;
 }
 
 bool cHardwareCPU::Inst_IfLess0()       // Execute next if ?bx? != 0.
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  if (Register(reg_used) >= 0)  IP().Advance();
+  if (GetRegister(reg_used) >= 0)  IP().Advance();
   return true;
 }
 
@@ -1850,14 +1845,14 @@
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
   const int reg_used2 = FindComplementRegister(reg_used);
-  if (Register(reg_used) >=  Register(reg_used2))  IP().Advance();
+  if (GetRegister(reg_used) >=  GetRegister(reg_used2))  IP().Advance();
   return true;
 }
 
 bool cHardwareCPU::Inst_IfLsEqu0()       // Execute next if ?bx? != 0.
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  if (Register(reg_used) > 0) IP().Advance();
+  if (GetRegister(reg_used) > 0) IP().Advance();
   return true;
 }
 
@@ -1865,32 +1860,32 @@
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
   const int reg_used2 = FindComplementRegister(reg_used);
-  if (Register(reg_used) >  Register(reg_used2))  IP().Advance();
+  if (GetRegister(reg_used) >  GetRegister(reg_used2))  IP().Advance();
   return true;
 }
 
 bool cHardwareCPU::Inst_IfBit1()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  if ((Register(reg_used) & 1) == 0)  IP().Advance();
-  return true;
+  if ((GetRegister(reg_used) & 1) == 0)  IP().Advance();
+return true;
 }
 
 bool cHardwareCPU::Inst_IfANotEqB()     // Execute next if AX != BX
 {
-  if (Register(nHardwareCPU::REG_AX) == Register(nHardwareCPU::REG_BX) )  IP().Advance();
+  if (GetRegister(nHardwareCPU::REG_AX) == GetRegister(nHardwareCPU::REG_BX) )  IP().Advance();
   return true;
 }
 
 bool cHardwareCPU::Inst_IfBNotEqC()     // Execute next if BX != CX
 {
-  if (Register(nHardwareCPU::REG_BX) == Register(nHardwareCPU::REG_CX) )  IP().Advance();
+  if (GetRegister(nHardwareCPU::REG_BX) == GetRegister(nHardwareCPU::REG_CX) )  IP().Advance();
   return true;
 }
 
 bool cHardwareCPU::Inst_IfANotEqC()     // Execute next if AX != BX
 {
-  if (Register(nHardwareCPU::REG_AX) == Register(nHardwareCPU::REG_CX) )  IP().Advance();
+  if (GetRegister(nHardwareCPU::REG_AX) == GetRegister(nHardwareCPU::REG_CX) )  IP().Advance();
   return true;
 }
 
@@ -1898,23 +1893,23 @@
 {
   ReadLabel();
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
-
+  
   // If there is no label, jump BX steps.
   if (GetLabel().GetSize() == 0) {
-    GetActiveHead().Jump(Register(nHardwareCPU::REG_BX));
+    GetActiveHead().Jump(GetRegister(nHardwareCPU::REG_BX));
     return true;
   }
-
+  
   // Otherwise, try to jump to the complement label.
   const cHeadCPU jump_location(FindLabel(1));
   if ( jump_location.GetPosition() != -1 ) {
     GetActiveHead().Set(jump_location);
     return true;
   }
-
+  
   // If complement label was not found; record an error.
   organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
-		  "jump-f: No complement label");
+                  "jump-f: No complement label");
   return false;
 }
 
@@ -1923,30 +1918,30 @@
 {
   ReadLabel();
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
-
+  
   // If there is no label, jump BX steps.
   if (GetLabel().GetSize() == 0) {
-    GetActiveHead().Jump(-Register(nHardwareCPU::REG_BX));
+    GetActiveHead().Jump(GetRegister(nHardwareCPU::REG_BX));
     return true;
   }
-
+  
   // otherwise jump to the complement label.
   const cHeadCPU jump_location(FindLabel(-1));
   if ( jump_location.GetPosition() != -1 ) {
     GetActiveHead().Set(jump_location);
     return true;
   }
-
+  
   // If complement label was not found; record an error.
   organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
-		  "jump-b: No complement label");
+                  "jump-b: No complement label");
   return false;
 }
 
 bool cHardwareCPU::Inst_JumpP()
 {
   cOrganism * other_organism = organism->GetNeighbor();
-
+  
   // Make sure the other organism was found and that its hardware is of the
   // same type, or else we won't be able to be parasitic on it.
   if (other_organism == NULL ||
@@ -1957,21 +1952,21 @@
     organism->GetPhenotype().IsParasite() = true;
     return true;
   }
-
+  
   // Otherwise, grab the hardware from the neighbor, and use it!
   cHardwareCPU & other_hardware = (cHardwareCPU &) other_organism->GetHardware();
-
+  
   ReadLabel();
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
-
+  
   // If there is no label, jump to line BX in creature.
   if (GetLabel().GetSize() == 0) {
-    const int new_pos = Register(nHardwareCPU::REG_BX);
+    const int new_pos = GetRegister(nHardwareCPU::REG_BX);
     IP().Set(new_pos, &other_hardware);
     organism->GetPhenotype().IsParasite() = true;
     return true;
   }
-
+  
   // otherwise jump to the complement label.
   const cHeadCPU jump_location(other_hardware.FindFullLabel(GetLabel()));
   if (jump_location.GetPosition() != -1) {
@@ -1979,12 +1974,12 @@
     organism->GetPhenotype().IsParasite() = true;
     return true;
   }
-
+  
   // If complement label was not found; record a warning (since the
   // actual neighbors are not under the organisms control, this is not
   // a full-scale error).
   organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_WARNING,
-		  "jump-p: No complement label");
+                  "jump-p: No complement label");
   return false;
 }
 
@@ -1992,23 +1987,23 @@
 {
   ReadLabel();
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
-
+  
   // If there is no label, jump to line BX in creature.
   if (GetLabel().GetSize() == 0) {
-    IP().Set(Register(nHardwareCPU::REG_BX), this);
+    IP().Set(GetRegister(nHardwareCPU::REG_BX), this);
     return true;
   }
-
+  
   // otherwise jump to the complement label.
   const cHeadCPU jump_location( FindFullLabel(GetLabel()) );
   if ( jump_location.GetPosition() != -1 ) {
     IP().Set(jump_location);
     return true;
   }
-
+  
   // If complement label was not found; record an error.
   organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
-		  "jump-slf: no complement label");
+                  "jump-slf: no complement label");
   return false;
 }
 
@@ -2017,25 +2012,25 @@
   // Put the starting location onto the stack
   const int location = IP().GetPosition();
   StackPush(location);
-
+  
   // Jump to the compliment label (or by the ammount in the bx register)
   ReadLabel();
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
-
+  
   if (GetLabel().GetSize() == 0) {
-    IP().Jump(Register(nHardwareCPU::REG_BX));
+    IP().Jump(GetRegister(nHardwareCPU::REG_BX));
     return true;
   }
-
+  
   const cHeadCPU jump_location(FindLabel(1));
   if (jump_location.GetPosition() != -1) {
     IP().Set(jump_location);
     return true;
   }
-
+  
   // If complement label was not found; record an error.
   organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
-		  "call: no complement label");
+                  "call: no complement label");
   return false;
 }
 
@@ -2048,14 +2043,14 @@
 bool cHardwareCPU::Inst_Pop()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = StackPop();
+  GetRegister(reg_used) = StackPop();
   return true;
 }
 
 bool cHardwareCPU::Inst_Push()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  StackPush(Register(reg_used));
+  StackPush(GetRegister(reg_used));
   return true;
 }
 
@@ -2078,13 +2073,13 @@
 }
 
 
-bool cHardwareCPU::Inst_PopA() { Register(nHardwareCPU::REG_AX) = StackPop(); return true;}
-bool cHardwareCPU::Inst_PopB() { Register(nHardwareCPU::REG_BX) = StackPop(); return true;}
-bool cHardwareCPU::Inst_PopC() { Register(nHardwareCPU::REG_CX) = StackPop(); return true;}
+bool cHardwareCPU::Inst_PopA() { GetRegister(nHardwareCPU::REG_AX) = StackPop(); return true;}
+bool cHardwareCPU::Inst_PopB() { GetRegister(nHardwareCPU::REG_BX) = StackPop(); return true;}
+bool cHardwareCPU::Inst_PopC() { GetRegister(nHardwareCPU::REG_CX) = StackPop(); return true;}
 
-bool cHardwareCPU::Inst_PushA() { StackPush(Register(nHardwareCPU::REG_AX)); return true;}
-bool cHardwareCPU::Inst_PushB() { StackPush(Register(nHardwareCPU::REG_BX)); return true;}
-bool cHardwareCPU::Inst_PushC() { StackPush(Register(nHardwareCPU::REG_CX)); return true;}
+bool cHardwareCPU::Inst_PushA() { StackPush(GetRegister(nHardwareCPU::REG_AX)); return true;}
+bool cHardwareCPU::Inst_PushB() { StackPush(GetRegister(nHardwareCPU::REG_BX)); return true;}
+bool cHardwareCPU::Inst_PushC() { StackPush(GetRegister(nHardwareCPU::REG_CX)); return true;}
 
 bool cHardwareCPU::Inst_SwitchStack() { SwitchStack(); return true;}
 bool cHardwareCPU::Inst_FlipStack()   { StackFlip(); return true;}
@@ -2093,46 +2088,40 @@
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
   const int other_reg = FindComplementRegister(reg_used);
-//  cout << endl; 
-//  cout << "Regs 1, 2, 3 are: " << Register(1) << " " << Register(2) << " " << Register(3) << endl; 
-//  cout << "Modified reg = " << reg_used << ", Complement reg = " << other_reg << endl; 
-//  cout << "Calling Swap with " << Register(reg_used) << " and " << Register(other_reg) << endl; 
-  nFunctions::Swap(Register(reg_used), Register(other_reg));
-//  cout << "Current State is " << Register(reg_used) << " and " << Register(other_reg) << endl; 
-//  cout << "Regs 1, 2, 3 are: " << Register(1) << " " << Register(2) << " " << Register(3) << endl; 
+  nFunctions::Swap(GetRegister(reg_used), GetRegister(other_reg));
   return true;
 }
 
-bool cHardwareCPU::Inst_SwapAB() { nFunctions::Swap(Register(nHardwareCPU::REG_AX), Register(nHardwareCPU::REG_BX)); return true; }
-bool cHardwareCPU::Inst_SwapBC() { nFunctions::Swap(Register(nHardwareCPU::REG_BX), Register(nHardwareCPU::REG_CX)); return true; }
-bool cHardwareCPU::Inst_SwapAC() { nFunctions::Swap(Register(nHardwareCPU::REG_AX), Register(nHardwareCPU::REG_CX)); return true; }
+bool cHardwareCPU::Inst_SwapAB() { nFunctions::Swap(GetRegister(nHardwareCPU::REG_AX), GetRegister(nHardwareCPU::REG_BX)); return true; }
+bool cHardwareCPU::Inst_SwapBC() { nFunctions::Swap(GetRegister(nHardwareCPU::REG_BX), GetRegister(nHardwareCPU::REG_CX)); return true; }
+bool cHardwareCPU::Inst_SwapAC() { nFunctions::Swap(GetRegister(nHardwareCPU::REG_AX), GetRegister(nHardwareCPU::REG_CX)); return true; }
 
 bool cHardwareCPU::Inst_CopyReg()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
   const int other_reg = FindComplementRegister(reg_used);
-  Register(other_reg) = Register(reg_used);
+  GetRegister(other_reg) = GetRegister(reg_used);
   return true;
 }
 
-bool cHardwareCPU::Inst_CopyRegAB() { Register(nHardwareCPU::REG_AX) = Register(nHardwareCPU::REG_BX);   return true;
+bool cHardwareCPU::Inst_CopyRegAB() {GetRegister(nHardwareCPU::REG_AX) = GetRegister(nHardwareCPU::REG_BX);   return true;
 }
-bool cHardwareCPU::Inst_CopyRegAC() { Register(nHardwareCPU::REG_AX) = Register(nHardwareCPU::REG_CX);   return true;
+bool cHardwareCPU::Inst_CopyRegAC() {GetRegister(nHardwareCPU::REG_AX) = GetRegister(nHardwareCPU::REG_CX);   return true;
 }
-bool cHardwareCPU::Inst_CopyRegBA() { Register(nHardwareCPU::REG_BX) = Register(nHardwareCPU::REG_AX);   return true;
+bool cHardwareCPU::Inst_CopyRegBA() {GetRegister(nHardwareCPU::REG_BX) = GetRegister(nHardwareCPU::REG_AX);   return true;
 }
-bool cHardwareCPU::Inst_CopyRegBC() { Register(nHardwareCPU::REG_BX) = Register(nHardwareCPU::REG_CX);   return true;
+bool cHardwareCPU::Inst_CopyRegBC() {GetRegister(nHardwareCPU::REG_BX) = GetRegister(nHardwareCPU::REG_CX);   return true;
 }
-bool cHardwareCPU::Inst_CopyRegCA() { Register(nHardwareCPU::REG_CX) = Register(nHardwareCPU::REG_AX);   return true;
+bool cHardwareCPU::Inst_CopyRegCA() {GetRegister(nHardwareCPU::REG_CX) = GetRegister(nHardwareCPU::REG_AX);   return true;
 }
-bool cHardwareCPU::Inst_CopyRegCB() { Register(nHardwareCPU::REG_CX) = Register(nHardwareCPU::REG_BX);   return true;
+bool cHardwareCPU::Inst_CopyRegCB() {GetRegister(nHardwareCPU::REG_CX) = GetRegister(nHardwareCPU::REG_BX);   return true;
 }
 
 bool cHardwareCPU::Inst_Reset()
 {
-  Register(nHardwareCPU::REG_AX) = 0;
-  Register(nHardwareCPU::REG_BX) = 0;
-  Register(nHardwareCPU::REG_CX) = 0;
+  GetRegister(nHardwareCPU::REG_AX) = 0;
+  GetRegister(nHardwareCPU::REG_BX) = 0;
+  GetRegister(nHardwareCPU::REG_CX) = 0;
   StackClear();
   return true;
 }
@@ -2140,101 +2129,101 @@
 bool cHardwareCPU::Inst_ShiftR()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) >>= 1;
+  GetRegister(reg_used) >>= 1;
   return true;
 }
 
 bool cHardwareCPU::Inst_ShiftL()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) <<= 1;
+  GetRegister(reg_used) <<= 1;
   return true;
 }
 
 bool cHardwareCPU::Inst_Bit1()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) |=  1;
+  GetRegister(reg_used) |=  1;
   return true;
 }
 
 bool cHardwareCPU::Inst_SetNum()
 {
   ReadLabel();
-  Register(nHardwareCPU::REG_BX) = GetLabel().AsInt(nHardwareCPU::NUM_NOPS);
+  GetRegister(nHardwareCPU::REG_BX) = GetLabel().AsInt(nHardwareCPU::NUM_NOPS);
   return true;
 }
 
 bool cHardwareCPU::Inst_ValGrey(void) {
   ReadLabel();
-  Register(nHardwareCPU::REG_BX) = GetLabel().AsIntGreyCode(nHardwareCPU::NUM_NOPS);
+  GetRegister(nHardwareCPU::REG_BX) = GetLabel().AsIntGreyCode(nHardwareCPU::NUM_NOPS);
   return true;
 }
 
 bool cHardwareCPU::Inst_ValDir(void) {
   ReadLabel();
-  Register(nHardwareCPU::REG_BX) = GetLabel().AsIntDirect(nHardwareCPU::NUM_NOPS);
+  GetRegister(nHardwareCPU::REG_BX) = GetLabel().AsIntDirect(nHardwareCPU::NUM_NOPS);
   return true;
 }
 
 bool cHardwareCPU::Inst_ValAddP(void) {
   ReadLabel();
-  Register(nHardwareCPU::REG_BX) = GetLabel().AsIntAdditivePolynomial(nHardwareCPU::NUM_NOPS);
+  GetRegister(nHardwareCPU::REG_BX) = GetLabel().AsIntAdditivePolynomial(nHardwareCPU::NUM_NOPS);
   return true;
 }
 
 bool cHardwareCPU::Inst_ValFib(void) {
   ReadLabel();
-  Register(nHardwareCPU::REG_BX) = GetLabel().AsIntFib(nHardwareCPU::NUM_NOPS);
+  GetRegister(nHardwareCPU::REG_BX) = GetLabel().AsIntFib(nHardwareCPU::NUM_NOPS);
   return true;
 }
 
 bool cHardwareCPU::Inst_ValPolyC(void) {
   ReadLabel();
-  Register(nHardwareCPU::REG_BX) = GetLabel().AsIntPolynomialCoefficent(nHardwareCPU::NUM_NOPS);
+  GetRegister(nHardwareCPU::REG_BX) = GetLabel().AsIntPolynomialCoefficent(nHardwareCPU::NUM_NOPS);
   return true;
 }
 
 bool cHardwareCPU::Inst_Inc()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) += 1;
+  GetRegister(reg_used) += 1;
   return true;
 }
 
 bool cHardwareCPU::Inst_Dec()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) -= 1;
+  GetRegister(reg_used) -= 1;
   return true;
 }
 
 bool cHardwareCPU::Inst_Zero()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = 0;
+  GetRegister(reg_used) = 0;
   return true;
 }
 
 bool cHardwareCPU::Inst_Neg()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = 0-Register(reg_used);
+  GetRegister(reg_used) = 0 - GetRegister(reg_used);
   return true;
 }
 
 bool cHardwareCPU::Inst_Square()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = Register(reg_used) * Register(reg_used);
+  GetRegister(reg_used) = GetRegister(reg_used) * GetRegister(reg_used);
   return true;
 }
 
 bool cHardwareCPU::Inst_Sqrt()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  const int value = Register(reg_used);
-  if (value > 1) Register(reg_used) = (int) sqrt((double) value);
+  const int value = GetRegister(reg_used);
+  if (value > 1) GetRegister(reg_used) = (int) sqrt((double) value);
   else if (value < 0) {
     Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "sqrt: value is negative");
     return false;
@@ -2245,8 +2234,8 @@
 bool cHardwareCPU::Inst_Log()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  const int value = Register(reg_used);
-  if (value >= 1) Register(reg_used) = (int) log((double) value);
+  const int value = GetRegister(reg_used);
+  if (value >= 1) GetRegister(reg_used) = (int) log((double) value);
   else if (value < 0) {
     Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "log: value is negative");
     return false;
@@ -2257,8 +2246,8 @@
 bool cHardwareCPU::Inst_Log10()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  const int value = Register(reg_used);
-  if (value >= 1) Register(reg_used) = (int) log10((double) value);
+  const int value = GetRegister(reg_used);
+  if (value >= 1) GetRegister(reg_used) = (int) log10((double) value);
   else if (value < 0) {
     Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "log10: value is negative");
     return false;
@@ -2269,39 +2258,39 @@
 bool cHardwareCPU::Inst_Minus17()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) -= 17;
+  GetRegister(reg_used) -= 17;
   return true;
 }
 
 bool cHardwareCPU::Inst_Add()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = Register(nHardwareCPU::REG_BX) + Register(nHardwareCPU::REG_CX);
+  GetRegister(reg_used) = GetRegister(nHardwareCPU::REG_BX) + GetRegister(nHardwareCPU::REG_CX);
   return true;
 }
 
 bool cHardwareCPU::Inst_Sub()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = Register(nHardwareCPU::REG_BX) - Register(nHardwareCPU::REG_CX);
+  GetRegister(reg_used) = GetRegister(nHardwareCPU::REG_BX) - GetRegister(nHardwareCPU::REG_CX);
   return true;
 }
 
 bool cHardwareCPU::Inst_Mult()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = Register(nHardwareCPU::REG_BX) * Register(nHardwareCPU::REG_CX);
+  GetRegister(reg_used) = GetRegister(nHardwareCPU::REG_BX) * GetRegister(nHardwareCPU::REG_CX);
   return true;
 }
 
 bool cHardwareCPU::Inst_Div()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  if (Register(nHardwareCPU::REG_CX) != 0) {
-    if (0-INT_MAX > Register(nHardwareCPU::REG_BX) && Register(nHardwareCPU::REG_CX) == -1)
+  if (GetRegister(nHardwareCPU::REG_CX) != 0) {
+    if (0-INT_MAX > GetRegister(nHardwareCPU::REG_BX) && GetRegister(nHardwareCPU::REG_CX) == -1)
       Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "div: Float exception");
     else
-      Register(reg_used) = Register(nHardwareCPU::REG_BX) / Register(nHardwareCPU::REG_CX);
+      GetRegister(reg_used) = GetRegister(nHardwareCPU::REG_BX) / GetRegister(nHardwareCPU::REG_CX);
   } else {
     Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "div: dividing by 0");
     return false;
@@ -2312,11 +2301,11 @@
 bool cHardwareCPU::Inst_Mod()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  if (Register(nHardwareCPU::REG_CX) != 0) {
-    Register(reg_used) = Register(nHardwareCPU::REG_BX) % Register(nHardwareCPU::REG_CX);
+  if (GetRegister(nHardwareCPU::REG_CX) != 0) {
+    GetRegister(reg_used) = GetRegister(nHardwareCPU::REG_BX) % GetRegister(nHardwareCPU::REG_CX);
   } else {
     Fault(FAULT_LOC_MATH, FAULT_TYPE_ERROR, "mod: modding by 0");
-  return false;
+    return false;
   }
   return true;
 }
@@ -2325,64 +2314,64 @@
 bool cHardwareCPU::Inst_Nand()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = ~(Register(nHardwareCPU::REG_BX) & Register(nHardwareCPU::REG_CX));
+  GetRegister(reg_used) = ~(GetRegister(nHardwareCPU::REG_BX) & GetRegister(nHardwareCPU::REG_CX));
   return true;
 }
 
 bool cHardwareCPU::Inst_Nor()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = ~(Register(nHardwareCPU::REG_BX) | Register(nHardwareCPU::REG_CX));
+  GetRegister(reg_used) = ~(GetRegister(nHardwareCPU::REG_BX) | GetRegister(nHardwareCPU::REG_CX));
   return true;
 }
 
 bool cHardwareCPU::Inst_And()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = (Register(nHardwareCPU::REG_BX) & Register(nHardwareCPU::REG_CX));
+  GetRegister(reg_used) = (GetRegister(nHardwareCPU::REG_BX) & GetRegister(nHardwareCPU::REG_CX));
   return true;
 }
 
 bool cHardwareCPU::Inst_Not()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = ~(Register(reg_used));
+  GetRegister(reg_used) = ~(GetRegister(reg_used));
   return true;
 }
 
 bool cHardwareCPU::Inst_Order()
 {
-  if (Register(nHardwareCPU::REG_BX) > Register(nHardwareCPU::REG_CX)) {
-    nFunctions::Swap(Register(nHardwareCPU::REG_BX), Register(nHardwareCPU::REG_CX));
+  if (GetRegister(nHardwareCPU::REG_BX) > GetRegister(nHardwareCPU::REG_CX)) {
+    nFunctions::Swap(GetRegister(nHardwareCPU::REG_BX), GetRegister(nHardwareCPU::REG_CX));
   }
-  return true;
+return true;
 }
 
 bool cHardwareCPU::Inst_Xor()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = Register(nHardwareCPU::REG_BX) ^ Register(nHardwareCPU::REG_CX);
+  GetRegister(reg_used) = GetRegister(nHardwareCPU::REG_BX) ^ GetRegister(nHardwareCPU::REG_CX);
   return true;
 }
 
 bool cHardwareCPU::Inst_Copy()
 {
-  const cHeadCPU from(this, Register(nHardwareCPU::REG_BX));
-  cHeadCPU to(this, Register(nHardwareCPU::REG_AX) + Register(nHardwareCPU::REG_BX));
+  const cHeadCPU from(this, GetRegister(nHardwareCPU::REG_BX));
+  cHeadCPU to(this, GetRegister(nHardwareCPU::REG_AX) + GetRegister(nHardwareCPU::REG_BX));
   sCPUStats & cpu_stats = organism->CPUStats();
-
+  
   if (organism->TestCopyMut()) {
-    to.SetInst(GetRandomInst());
+    to.SetInst(m_inst_set->GetRandomInst());
     to.FlagMutated() = true;  // Mark this instruction as mutated...
     to.FlagCopyMut() = true;  // Mark this instruction as copy mut...
-    //organism->GetPhenotype().IsMutated() = true;
+                              //organism->GetPhenotype().IsMutated() = true;
     cpu_stats.mut_stats.copy_mut_count++;
   } else {
     to.SetInst(from.GetInst());
     to.FlagMutated() = false;  // UnMark
     to.FlagCopyMut() = false;  // UnMark
   }
-
+  
   to.FlagCopied() = true;  // Set the copied flag.
   cpu_stats.mut_stats.copies_exec++;
   return true;
@@ -2391,43 +2380,43 @@
 bool cHardwareCPU::Inst_ReadInst()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_CX);
-  const cHeadCPU from(this, Register(nHardwareCPU::REG_BX));
-
+  const cHeadCPU from(this,GetRegister(nHardwareCPU::REG_BX));
+  
   // Dis-allowing mutations on read, for the moment (write only...)
   // @CAO This allows perfect error-correction...
-  Register(reg_used) = from.GetInst().GetOp();
+  GetRegister(reg_used) = from.GetInst().GetOp();
   return true;
 }
 
 bool cHardwareCPU::Inst_WriteInst()
 {
-  cHeadCPU to(this, Register(nHardwareCPU::REG_AX) + Register(nHardwareCPU::REG_BX));
+  cHeadCPU to(this, GetRegister(nHardwareCPU::REG_AX) + GetRegister(nHardwareCPU::REG_BX));
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_CX);
-  const int value = Mod(Register(reg_used), GetNumInst());
-  sCPUStats & cpu_stats = organism->CPUStats();
+  const int value = Mod(GetRegister(reg_used), m_inst_set->GetSize());
+sCPUStats & cpu_stats = organism->CPUStats();
 
-  // Change value on a mutation...
-  if (organism->TestCopyMut()) {
-    to.SetInst(GetRandomInst());
-    to.FlagMutated() = true;      // Mark this instruction as mutated...
-    to.FlagCopyMut() = true;      // Mark this instruction as copy mut...
-    //organism->GetPhenotype().IsMutated() = true;
-    cpu_stats.mut_stats.copy_mut_count++;
-  } else {
-    to.SetInst(cInstruction(value));
-    to.FlagMutated() = false;     // UnMark
-    to.FlagCopyMut() = false;     // UnMark
-  }
+// Change value on a mutation...
+if (organism->TestCopyMut()) {
+  to.SetInst(m_inst_set->GetRandomInst());
+  to.FlagMutated() = true;      // Mark this instruction as mutated...
+  to.FlagCopyMut() = true;      // Mark this instruction as copy mut...
+                                //organism->GetPhenotype().IsMutated() = true;
+  cpu_stats.mut_stats.copy_mut_count++;
+} else {
+  to.SetInst(cInstruction(value));
+  to.FlagMutated() = false;     // UnMark
+  to.FlagCopyMut() = false;     // UnMark
+}
 
-  to.FlagCopied() = true;  // Set the copied flag.
-  cpu_stats.mut_stats.copies_exec++;
-  return true;
+to.FlagCopied() = true;  // Set the copied flag.
+cpu_stats.mut_stats.copies_exec++;
+return true;
 }
 
 bool cHardwareCPU::Inst_StackReadInst()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_CX);
-  cHeadCPU from(this, Register(reg_used));
+  cHeadCPU from(this, GetRegister(reg_used));
   StackPush(from.GetInst().GetOp());
   return true;
 }
@@ -2435,23 +2424,23 @@
 bool cHardwareCPU::Inst_StackWriteInst()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  cHeadCPU to(this, Register(nHardwareCPU::REG_AX) + Register(reg_used));
-  const int value = Mod(StackPop(), GetNumInst());
+  cHeadCPU to(this, GetRegister(nHardwareCPU::REG_AX) + GetRegister(reg_used));
+  const int value = Mod(StackPop(), m_inst_set->GetSize());
   sCPUStats & cpu_stats = organism->CPUStats();
-
+  
   // Change value on a mutation...
   if (organism->TestCopyMut()) {
-    to.SetInst(GetRandomInst());
+    to.SetInst(m_inst_set->GetRandomInst());
     to.FlagMutated() = true;      // Mark this instruction as mutated...
     to.FlagCopyMut() = true;      // Mark this instruction as copy mut...
-    //organism->GetPhenotype().IsMutated() = true;
+                                  //organism->GetPhenotype().IsMutated() = true;
     cpu_stats.mut_stats.copy_mut_count++;
   } else {
     to.SetInst(cInstruction(value));
     to.FlagMutated() = false;     // UnMark
     to.FlagCopyMut() = false;     // UnMark
   }
-
+  
   to.FlagCopied() = true;  // Set the copied flag.
   cpu_stats.mut_stats.copies_exec++;
   return true;
@@ -2460,27 +2449,27 @@
 bool cHardwareCPU::Inst_Compare()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_CX);
-  cHeadCPU from(this, Register(nHardwareCPU::REG_BX));
-  cHeadCPU to(this, Register(nHardwareCPU::REG_AX) + Register(nHardwareCPU::REG_BX));
-
+  cHeadCPU from(this, GetRegister(nHardwareCPU::REG_BX));
+  cHeadCPU to(this, GetRegister(nHardwareCPU::REG_AX) + GetRegister(nHardwareCPU::REG_BX));
+  
   // Compare is dangerous -- it can cause mutations!
   if (organism->TestCopyMut()) {
-    to.SetInst(GetRandomInst());
+    to.SetInst(m_inst_set->GetRandomInst());
     to.FlagMutated() = true;      // Mark this instruction as mutated...
     to.FlagCopyMut() = true;      // Mark this instruction as copy mut...
-    //organism->GetPhenotype().IsMutated() = true;
+                                  //organism->GetPhenotype().IsMutated() = true;
   }
-
-  Register(reg_used) = from.GetInst().GetOp() - to.GetInst().GetOp();
-
+  
+  GetRegister(reg_used) = from.GetInst().GetOp() - to.GetInst().GetOp();
+  
   return true;
 }
 
 bool cHardwareCPU::Inst_IfNCpy()
 {
-  const cHeadCPU from(this, Register(nHardwareCPU::REG_BX));
-  const cHeadCPU to(this, Register(nHardwareCPU::REG_AX) + Register(nHardwareCPU::REG_BX));
-
+  const cHeadCPU from(this, GetRegister(nHardwareCPU::REG_BX));
+  const cHeadCPU to(this, GetRegister(nHardwareCPU::REG_AX) + GetRegister(nHardwareCPU::REG_BX));
+  
   // Allow for errors in this test...
   if (organism->TestCopyMut()) {
     if (from.GetInst() != to.GetInst()) IP().Advance();
@@ -2493,15 +2482,15 @@
 bool cHardwareCPU::Inst_Allocate()   // Allocate bx more space...
 {
   const int size = GetMemory().GetSize();
-  if( Allocate_Main(Register(nHardwareCPU::REG_BX)) ) {
-    Register(nHardwareCPU::REG_AX) = size;
-    return true;
-  } else return false;
+  if( Allocate_Main(GetRegister(nHardwareCPU::REG_BX)) ) {
+  GetRegister(nHardwareCPU::REG_AX) = size;
+  return true;
+} else return false;
 }
 
 bool cHardwareCPU::Inst_Divide()  
 { 
-  return Divide_Main(Register(nHardwareCPU::REG_AX));    
+  return Divide_Main(GetRegister(nHardwareCPU::REG_AX));    
 }
 
 bool cHardwareCPU::Inst_CDivide() 
@@ -2518,9 +2507,9 @@
 {
   const int cur_size = GetMemory().GetSize();
   const int alloc_size = Min((int) (m_world->GetConfig().CHILD_SIZE_RANGE.Get() * cur_size),
-			     MAX_CREATURE_SIZE - cur_size);
+                             MAX_CREATURE_SIZE - cur_size);
   if( Allocate_Main(alloc_size) ) {
-    Register(nHardwareCPU::REG_AX) = cur_size;
+    GetRegister(nHardwareCPU::REG_AX) = cur_size;
     return true;
   } else return false;
 }
@@ -2532,40 +2521,40 @@
   cCPUMemory & child_genome = organism->ChildGenome();
   child_genome = GetMemory();
   organism->GetPhenotype().SetLinesCopied(GetMemory().GetSize());
-
+  
   int lines_executed = 0;
   for ( int i = 0; i < GetMemory().GetSize(); i++ ) {
     if ( GetMemory().FlagExecuted(i) == true ) lines_executed++;
   }
   organism->GetPhenotype().SetLinesExecuted(lines_executed);
-
+  
   // Perform Copy Mutations...
   if (organism->GetCopyMutProb() > 0) { // Skip this if no mutations....
     for (int i = 0; i < GetMemory().GetSize(); i++) {
       if (organism->TestCopyMut()) {
-	child_genome[i]=GetRandomInst();
-	//organism->GetPhenotype().IsMutated() = true;
+        child_genome[i] = m_inst_set->GetRandomInst();
+        //organism->GetPhenotype().IsMutated() = true;
       }
     }
   }
   Divide_DoMutations();
-
+  
   // Many tests will require us to run the offspring through a test CPU;
   // this is, for example, to see if mutations need to be reverted or if
   // lineages need to be updated.
   Divide_TestFitnessMeasures();
-
+  
 #ifdef INSTRUCTION_COSTS
   // reset first time instruction costs
   for (int i = 0; i < inst_ft_cost.GetSize(); i++) {
-    inst_ft_cost[i] = GetInstSet().GetFTCost(cInstruction(i));
+    inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
   }
 #endif
-
+  
   if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) advance_ip = false;
-
+  
   organism->ActivateDivide();
-
+  
   return true;
 }
 
@@ -2573,7 +2562,7 @@
 bool cHardwareCPU::Inst_Kazi()
 {
 	const int reg_used = FindModifiedRegister(nHardwareCPU::REG_AX);
-	int percentProb = Register(reg_used) % 100;
+	int percentProb = GetRegister(reg_used) % 100;
 	int random = abs(rand()) % 100;
 	if (random >= percentProb)
 	{
@@ -2588,9 +2577,9 @@
 
 bool cHardwareCPU::Inst_Die()
 {
-   const double die_prob = m_world->GetConfig().DIE_PROB.Get();
-   if(m_world->GetRandom().GetDouble() < die_prob) { organism->Die(); }
-   return true; 
+  const double die_prob = m_world->GetConfig().DIE_PROB.Get();
+  if(m_world->GetRandom().GetDouble() < die_prob) { organism->Die(); }
+  return true; 
 }
 
 // The inject instruction can be used instead of a divide command, paired
@@ -2607,7 +2596,7 @@
   const int start_pos = GetHead(nHardware::HEAD_READ).GetPosition();
   const int end_pos = GetHead(nHardware::HEAD_WRITE).GetPosition();
   const int inject_size = end_pos - start_pos;
-
+  
   // Make sure the creature will still be above the minimum size,
   if (inject_size <= 0) {
     Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: no code to inject");
@@ -2617,36 +2606,36 @@
     Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: new size too small");
     return false; // (inject fails)
   }
-
+  
   // Since its legal to cut out the injected piece, do so.
   cGenome inject_code( cGenomeUtil::Crop(GetMemory(), start_pos, end_pos) );
   GetMemory().Remove(start_pos, inject_size);
-
+  
   // If we don't have a host, stop here.
   cOrganism * host_organism = organism->GetNeighbor();
   if (host_organism == NULL) return false;
-
+  
   // Scan for the label to match...
   ReadLabel();
-
+  
   // If there is no label, abort.
   if (GetLabel().GetSize() == 0) {
     Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: label required");
     return false; // (inject fails)
   }
-
+  
   // Search for the label in the host...
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
-
+  
   const bool inject_signal = host_organism->GetHardware().InjectHost(GetLabel(), inject_code);
   if (inject_signal) {
     Fault(FAULT_LOC_INJECT, FAULT_TYPE_WARNING, "inject: host too large.");
     return false; // Inject failed.
   }
-
+  
   // Set the relevent flags.
   organism->GetPhenotype().IsModifier() = true;
-
+  
   return inject_signal;
 }
 
@@ -2674,7 +2663,7 @@
   const int start_pos = GetHead(nHardware::HEAD_READ).GetPosition();
   const int end_pos = GetHead(nHardware::HEAD_WRITE).GetPosition();
   const int inject_size = end_pos - start_pos;
-
+  
   // Make sure the creature will still be above the minimum size,
   if (inject_size <= 0) {
     Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: no code to inject");
@@ -2684,27 +2673,27 @@
     Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: new size too small");
     return false; // (inject fails)
   }
-
+  
   // Since its legal to cut out the injected piece, do so.
   cGenome inject_code( cGenomeUtil::Crop(GetMemory(), start_pos, end_pos) );
   GetMemory().Remove(start_pos, inject_size);
-
+  
   // If we don't have a host, stop here.
   cOrganism * host_organism = organism->GetNeighbor();
   if (host_organism == NULL) return false;
-
+  
   // Scan for the label to match...
   ReadLabel();
-
+  
   // If there is no label, abort.
   if (GetLabel().GetSize() == 0) {
     Fault(FAULT_LOC_INJECT, FAULT_TYPE_ERROR, "inject: label required");
     return false; // (inject fails)
   }
-
+  
   // Search for the label in the host...
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
-
+  
   const int inject_signal =
     host_organism->GetHardware().InjectThread(GetLabel(), inject_code);
   if (inject_signal == 1) {
@@ -2715,10 +2704,10 @@
     Fault(FAULT_LOC_INJECT, FAULT_TYPE_WARNING, "inject: target not in host.");
     return false; // Inject failed.
   }
-
+  
   // Set the relevent flags.
   organism->GetPhenotype().IsModifier() = true;
-
+  
   return true;
 }
 
@@ -2726,7 +2715,7 @@
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_CX);
   const int value = organism->GetNextInput();
-  Register(reg_used) = value;
+  GetRegister(reg_used) = value;
   organism->DoInput(value);
   return true;
 }
@@ -2749,8 +2738,8 @@
 bool cHardwareCPU::Inst_TaskPut()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  const int value = Register(reg_used);
-  Register(reg_used) = 0;
+  const int value = GetRegister(reg_used);
+  GetRegister(reg_used) = 0;
   organism->DoOutput(value);
   return true;
 }
@@ -2758,14 +2747,14 @@
 bool cHardwareCPU::Inst_TaskIO()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-
+  
   // Do the "put" component
-  const int value_out = Register(reg_used);
+  const int value_out = GetRegister(reg_used);
   organism->DoOutput(value_out);  // Check for tasks compleated.
-
+  
   // Do the "get" component
   const int value_in = organism->GetNextInput();
-  Register(reg_used) = value_in;
+  GetRegister(reg_used) = value_in;
   organism->DoInput(value_in);
   return true;
 }
@@ -2773,15 +2762,15 @@
 bool cHardwareCPU::Inst_Send()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  organism->SendValue(Register(reg_used));
-  Register(reg_used) = 0;
-  return true;
+  organism->SendValue(GetRegister(reg_used));
+GetRegister(reg_used) = 0;
+return true;
 }
 
 bool cHardwareCPU::Inst_Receive()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = organism->ReceiveValue();
+  GetRegister(reg_used) = organism->ReceiveValue();
   return true;
 }
 
@@ -2789,33 +2778,33 @@
 {
   const tArray<double> & res_count = organism->PopInterface().GetResources();
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-
+  
   // If there are no resources to measure, this instruction fails.
   if (res_count.GetSize() == 0) return false;
-
+  
   // Always get the first resource, and convert it to and int.
-  Register(reg_used) = (int) res_count[0];
-
+  GetRegister(reg_used) = (int) res_count[0];
+  
   // @CAO Since resources are sometimes less than one, perhaps we should
   // multiply it by some constant?  Or perhaps taking the log would be more
   // useful so they can easily scan across orders of magnitude?
-
+  
   return true;
 }
 
 void cHardwareCPU::DoDonate(cOrganism * to_org)
 {
   assert(to_org != NULL);
-
+  
   const double merit_given = m_world->GetConfig().MERIT_GIVEN.Get();
   const double merit_received = m_world->GetConfig().MERIT_RECEIVED.Get();
-
+  
   double cur_merit = organism->GetPhenotype().GetMerit().GetDouble();
   cur_merit -= merit_given; 
-
+  
   // Plug the current merit back into this organism and notify the scheduler.
   organism->UpdateMerit(cur_merit);
-
+  
   // Update the merit of the organism being donated to...
   double other_merit = to_org->GetPhenotype().GetMerit().GetDouble();
   other_merit += merit_received;
@@ -2828,13 +2817,13 @@
   if (organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
+  
   // Turn to a random neighbor, get it, and turn back...
   int neighbor_id = m_world->GetRandom().GetInt(organism->GetNeighborhoodSize());
   for (int i = 0; i < neighbor_id; i++) organism->Rotate(1);
   cOrganism * neighbor = organism->GetNeighbor();
   for (int i = 0; i < neighbor_id; i++) organism->Rotate(-1);
-
+  
   // Donate only if we have found a neighbor.
   if (neighbor != NULL) DoDonate(neighbor);
   
@@ -2848,15 +2837,15 @@
   if (organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
+  
   // Find the target as the first Kin found in the neighborhood.
   const int num_neighbors = organism->GetNeighborhoodSize();
-
+  
   // Turn to face a random neighbor
   int neighbor_id = m_world->GetRandom().GetInt(num_neighbors);
   for (int i = 0; i < neighbor_id; i++) organism->Rotate(1);
   cOrganism * neighbor = organism->GetNeighbor();
-
+  
   // If there is no max distance, just take the random neighbor we're facing.
   const int max_dist = m_world->GetConfig().MAX_DONATE_KIN_DIST.Get();
   if (max_dist != -1) {
@@ -2866,22 +2855,22 @@
     while (neighbor_id < max_id) {
       neighbor = organism->GetNeighbor();
       if (neighbor != NULL &&
-	  genotype->GetPhyloDistance(neighbor->GetGenotype()) <= max_dist) {
-	found = true;
-	break;
+          genotype->GetPhyloDistance(neighbor->GetGenotype()) <= max_dist) {
+        found = true;
+        break;
       }
       organism->Rotate(1);
       neighbor_id++;
     }
     if (found == false) neighbor = NULL;
   }
-
+  
   // Put the facing back where it was.
   for (int i = 0; i < neighbor_id; i++) organism->Rotate(-1);
-
+  
   // Donate only if we have found a close enough relative...
   if (neighbor != NULL)  DoDonate(neighbor);
-
+  
   return true;
 }
 
@@ -2891,15 +2880,15 @@
   if (organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
+  
   // Find the target as the first Kin found in the neighborhood.
   const int num_neighbors = organism->GetNeighborhoodSize();
-
+  
   // Turn to face a random neighbor
   int neighbor_id = m_world->GetRandom().GetInt(num_neighbors);
   for (int i = 0; i < neighbor_id; i++) organism->Rotate(1);
   cOrganism * neighbor = organism->GetNeighbor();
-
+  
   // If there is no max edit distance, take the random neighbor we're facing.
   const int max_dist = m_world->GetConfig().MAX_DONATE_EDIT_DIST.Get();
   if (max_dist != -1) {
@@ -2909,25 +2898,25 @@
       neighbor = organism->GetNeighbor();
       int edit_dist = max_dist + 1;
       if (neighbor != NULL) {
-	edit_dist = cGenomeUtil::FindEditDistance(organism->GetGenome(),
-						  neighbor->GetGenome());
+        edit_dist = cGenomeUtil::FindEditDistance(organism->GetGenome(),
+                                                  neighbor->GetGenome());
       }
       if (edit_dist <= max_dist) {
-	found = true;
-	break;
+        found = true;
+        break;
       }
       organism->Rotate(1);
       neighbor_id++;
     }
     if (found == false) neighbor = NULL;
   }
-
+  
   // Put the facing back where it was.
   for (int i = 0; i < neighbor_id; i++) organism->Rotate(-1);
-
+  
   // Donate only if we have found a close enough relative...
   if (neighbor != NULL)  DoDonate(neighbor);
-
+  
   return true;
 }
 
@@ -2938,17 +2927,17 @@
   if (organism->GetPhenotype().GetCurNumDonates() > m_world->GetConfig().MAX_DONATES.Get()) {
     return false;
   }
-
+  
   // This is a fake donate command that causes the organism to lose merit,
   // but no one else to gain any.
-
+  
   const double merit_given = m_world->GetConfig().MERIT_GIVEN.Get();
   double cur_merit = organism->GetPhenotype().GetMerit().GetDouble();
   cur_merit -= merit_given;
-
+  
   // Plug the current merit back into this organism and notify the scheduler.
   organism->UpdateMerit(cur_merit);
-
+  
   return true;
 }
 
@@ -2958,8 +2947,8 @@
   ReadLabel();
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
   const int search_size = FindLabel(1).GetPosition() - IP().GetPosition();
-  Register(nHardwareCPU::REG_BX) = search_size;
-  Register(nHardwareCPU::REG_CX) = GetLabel().GetSize();
+  GetRegister(nHardwareCPU::REG_BX) = search_size;
+  GetRegister(nHardwareCPU::REG_CX) = GetLabel().GetSize();
   return true;
 }
 
@@ -2968,14 +2957,14 @@
   ReadLabel();
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
   const int search_size = IP().GetPosition() - FindLabel(-1).GetPosition();
-  Register(nHardwareCPU::REG_BX) = search_size;
-  Register(nHardwareCPU::REG_CX) = GetLabel().GetSize();
+  GetRegister(nHardwareCPU::REG_BX) = search_size;
+  GetRegister(nHardwareCPU::REG_CX) = GetLabel().GetSize();
   return true;
 }
 
 bool cHardwareCPU::Inst_MemSize()
 {
-  Register(FindModifiedRegister(nHardwareCPU::REG_BX)) = GetMemory().GetSize();
+  GetRegister(FindModifiedRegister(nHardwareCPU::REG_BX)) = GetMemory().GetSize();
   return true;
 }
 
@@ -2983,33 +2972,33 @@
 bool cHardwareCPU::Inst_RotateL()
 {
   const int num_neighbors = organism->GetNeighborhoodSize();
-
-   // If this organism has no neighbors, ignore rotate.
+  
+  // If this organism has no neighbors, ignore rotate.
   if (num_neighbors == 0) return false;
-
+  
   ReadLabel();
-
+  
   // Always rotate at least once.
   organism->Rotate(-1);
-
+  
   // If there is no label, then the one rotation was all we want.
   if (!GetLabel().GetSize()) return true;
-
+  
   // Rotate until a complement label is found (or all have been checked).
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
   for (int i = 1; i < num_neighbors; i++) {
     cOrganism * neighbor = organism->GetNeighbor();
-
+    
     // Assuming we have a neighbor and it is of the same hardware type,
     // search for the label in it.
     if (neighbor != NULL &&
-	neighbor->GetHardware().GetType() == GetType()) {
-
+        neighbor->GetHardware().GetType() == GetType()) {
+      
       // If this facing has the full label, stop here.
       cHardwareCPU & cur_hardware = (cHardwareCPU &) neighbor->GetHardware();
       if (cur_hardware.FindFullLabel( GetLabel() ).InMemory()) return true;
     }
-
+    
     // Otherwise keep rotating...
     organism->Rotate(-1);
   }
@@ -3019,33 +3008,33 @@
 bool cHardwareCPU::Inst_RotateR()
 {
   const int num_neighbors = organism->GetNeighborhoodSize();
-
-   // If this organism has no neighbors, ignore rotate.
+  
+  // If this organism has no neighbors, ignore rotate.
   if (num_neighbors == 0) return false;
-
+  
   ReadLabel();
-
+  
   // Always rotate at least once.
   organism->Rotate(-1);
-
+  
   // If there is no label, then the one rotation was all we want.
   if (!GetLabel().GetSize()) return true;
-
+  
   // Rotate until a complement label is found (or all have been checked).
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
   for (int i = 1; i < num_neighbors; i++) {
     cOrganism * neighbor = organism->GetNeighbor();
-
+    
     // Assuming we have a neighbor and it is of the same hardware type,
     // search for the label in it.
     if (neighbor != NULL &&
-	neighbor->GetHardware().GetType() == GetType()) {
-
+        neighbor->GetHardware().GetType() == GetType()) {
+      
       // If this facing has the full label, stop here.
       cHardwareCPU & cur_hardware = (cHardwareCPU &) neighbor->GetHardware();
       if (cur_hardware.FindFullLabel( GetLabel() ).InMemory()) return true;
     }
-
+    
     // Otherwise keep rotating...
     organism->Rotate(1);
   }
@@ -3055,7 +3044,7 @@
 bool cHardwareCPU::Inst_SetCopyMut()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  const int new_mut_rate = Max( Register(reg_used), 1 );
+  const int new_mut_rate = Max(GetRegister(reg_used), 1 );
   organism->SetCopyMutProb(((double) new_mut_rate) / 10000.0);
   return true;
 }
@@ -3064,7 +3053,7 @@
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
   const double new_mut_rate = organism->GetCopyMutProb() +
-    ((double) Register(reg_used)) / 10000.0;
+    ((double)GetRegister(reg_used)) / 10000.0;
   if (new_mut_rate > 0.0) organism->SetCopyMutProb(new_mut_rate);
   return true;
 }
@@ -3089,7 +3078,7 @@
 bool cHardwareCPU::Inst_ThreadID()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_BX);
-  Register(reg_used) = GetCurThreadID();
+  GetRegister(reg_used) = GetCurThreadID();
   return true;
 }
 
@@ -3099,7 +3088,7 @@
 bool cHardwareCPU::Inst_SetHead()
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
-  SetActiveHead(head_used);
+  threads[cur_thread].cur_head = (UCHAR) head_used;
   return true;
 }
 
@@ -3109,7 +3098,7 @@
   GetHead(head_used).Advance();
   return true;
 }
- 
+
 bool cHardwareCPU::Inst_MoveHead()
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
@@ -3121,14 +3110,14 @@
 bool cHardwareCPU::Inst_JumpHead()
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
-  GetHead(head_used).Jump( Register(nHardwareCPU::REG_CX) );
+  GetHead(head_used).Jump(GetRegister(nHardwareCPU::REG_CX) );
   return true;
 }
 
 bool cHardwareCPU::Inst_GetHead()
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
-  Register(nHardwareCPU::REG_CX) = GetHead(head_used).GetPosition();
+  GetRegister(nHardwareCPU::REG_CX) = GetHead(head_used).GetPosition();
   return true;
 }
 
@@ -3148,7 +3137,7 @@
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
   if (GetLabel() != GetReadLabel()) {
     IP().Advance();
-    if (inst_set->IsNop( IP().GetNextInst() ))  IP().Advance();
+    if (m_inst_set->IsNop( IP().GetNextInst() ))  IP().Advance();
   }
   return true;
 }
@@ -3198,11 +3187,11 @@
   // other organisms this one is willing to mate with.
   ReadLabel();
   organism->GetPhenotype().SetMateSelectID( GetLabel().AsInt(nHardwareCPU::NUM_NOPS) );
-
-//   int mate_id = GetLabel().AsInt(nHardwareCPU::NUM_NOPS);
-//   if (mate_id > 0) cout << mate_id << " "
-// 			<< GetLabel().AsString() << endl;
-
+  
+  //   int mate_id = GetLabel().AsInt(nHardwareCPU::NUM_NOPS);
+  //   if (mate_id > 0) cout << mate_id << " "
+  // 			<< GetLabel().AsString() << endl;
+  
   // Proceed as normal with the rest of mate selection.
   organism->GetPhenotype().SetDivideSex(true);
   organism->GetPhenotype().SetCrossNum(1);
@@ -3239,18 +3228,18 @@
   const int head_id = FindModifiedHead(nHardware::HEAD_READ);
   GetHead(head_id).Adjust();
   sCPUStats & cpu_stats = organism->CPUStats();
-
+  
   // Mutations only occur on the read, for the moment.
   int read_inst = 0;
   if (organism->TestCopyMut()) {
-    read_inst = GetRandomInst().GetOp();
+    read_inst = m_inst_set->GetRandomInst().GetOp();
     cpu_stats.mut_stats.copy_mut_count++;  // @CAO, hope this is good!
   } else {
     read_inst = GetHead(head_id).GetInst().GetOp();
   }
-  Register(nHardwareCPU::REG_BX) = read_inst;
+  GetRegister(nHardwareCPU::REG_BX) = read_inst;
   ReadInst(read_inst);
-
+  
   cpu_stats.mut_stats.copies_exec++;  // @CAO, this too..
   GetHead(head_id).Advance();
   return true;
@@ -3260,15 +3249,15 @@
 {
   const int head_id = FindModifiedHead(nHardware::HEAD_WRITE);
   cHeadCPU & active_head = GetHead(head_id);
-
+  
   active_head.Adjust();
-
-  int value = Register(nHardwareCPU::REG_BX);
-  if (value < 0 || value >= GetNumInst()) value = 0;
-
+  
+  int value = GetRegister(nHardwareCPU::REG_BX);
+  if (value < 0 || value >= m_inst_set->GetSize()) value = 0;
+  
   active_head.SetInst(cInstruction(value));
   active_head.FlagCopied() = true;
-
+  
   // Advance the head after write...
   active_head++;
   return true;
@@ -3280,30 +3269,30 @@
   cHeadCPU & read_head = GetHead(nHardware::HEAD_READ);
   cHeadCPU & write_head = GetHead(nHardware::HEAD_WRITE);
   sCPUStats & cpu_stats = organism->CPUStats();
-
+  
   read_head.Adjust();
   write_head.Adjust();
-
+  
   // TriggerMutations(nMutation::TRIGGER_READ, read_head);
   
   // Do mutations.
   cInstruction read_inst = read_head.GetInst();
   ReadInst(read_inst.GetOp());
   if (organism->TestCopyMut()) {
-    read_inst = GetRandomInst();
+    read_inst = m_inst_set->GetRandomInst();
     cpu_stats.mut_stats.copy_mut_count++; 
     write_head.FlagMutated() = true;
     write_head.FlagCopyMut() = true;
     //organism->GetPhenotype().IsMutated() = true;
   }
-
+  
   cpu_stats.mut_stats.copies_exec++;
-
+  
   write_head.SetInst(read_inst);
   write_head.FlagCopied() = true;  // Set the copied flag...
-
+  
   // TriggerMutations(nMutation::TRIGGER_WRITE, write_head);
-
+  
   read_head.Advance();
   write_head.Advance();
   return true;
@@ -3315,26 +3304,26 @@
   cHeadCPU & read_head = GetHead(nHardware::HEAD_READ);
   cHeadCPU & write_head = GetHead(nHardware::HEAD_WRITE);
   sCPUStats & cpu_stats = organism->CPUStats();
-
+  
   read_head.Adjust();
   write_head.Adjust();
-
+  
   // Do mutations.
   cInstruction read_inst = read_head.GetInst();
   ReadInst(read_inst.GetOp());
   if ( m_world->GetRandom().P(organism->GetCopyMutProb() / reduction) ) {
-    read_inst = GetRandomInst();
+    read_inst = m_inst_set->GetRandomInst();
     cpu_stats.mut_stats.copy_mut_count++; 
     write_head.FlagMutated() = true;
     write_head.FlagCopyMut() = true;
     //organism->GetPhenotype().IsMutated() = true;
   }
-
+  
   cpu_stats.mut_stats.copies_exec++;
-
+  
   write_head.SetInst(read_inst);
   write_head.FlagCopied() = true;  // Set the copied flag...
-
+  
   read_head.Advance();
   write_head.Advance();
   return true;
@@ -3356,8 +3345,8 @@
   GetLabel().Rotate(1, nHardwareCPU::NUM_NOPS);
   cHeadCPU found_pos = FindLabel(0);
   const int search_size = found_pos.GetPosition() - IP().GetPosition();
-  Register(nHardwareCPU::REG_BX) = search_size;
-  Register(nHardwareCPU::REG_CX) = GetLabel().GetSize();
+  GetRegister(nHardwareCPU::REG_BX) = search_size;
+  GetRegister(nHardwareCPU::REG_CX) = GetLabel().GetSize();
   GetHead(nHardware::HEAD_FLOW).Set(found_pos);
   GetHead(nHardware::HEAD_FLOW).Advance();
   return true; 
@@ -3366,36 +3355,11 @@
 bool cHardwareCPU::Inst_SetFlow()
 {
   const int reg_used = FindModifiedRegister(nHardwareCPU::REG_CX);
-  GetHead(nHardware::HEAD_FLOW).Set(Register(reg_used), this);
-  return true; 
+  GetHead(nHardware::HEAD_FLOW).Set(GetRegister(reg_used), this);
+return true; 
 }
 
-// Direct Matching Templates
 
-bool cHardwareCPU::Inst_DMJumpF()
-{
-  ReadLabel();
-
-  // If there is no label, jump BX steps.
-  if (GetLabel().GetSize() == 0) {
-    IP().Jump(Register(nHardwareCPU::REG_BX));
-    return true;
-  }
-
-  // Otherwise, jump to the label.
-  cHeadCPU jump_location(FindLabel(1));
-  if (jump_location.GetPosition() != -1) {
-    IP().Set(jump_location);
-    return true;
-  }
-
-  // If complement label was not found; record an error.
-  organism->Fault(FAULT_LOC_JUMP, FAULT_TYPE_ERROR,
-		  "dm-jump-f: no complement label");
-  return false;
-}
-
-
 //// Placebo insts ////
 bool cHardwareCPU::Inst_Skip()
 {
@@ -3404,15 +3368,15 @@
 }
 
 
-  /*
-  FIXME: Breakage of interface. This function returns data that is
-  supposed to be private.
-
-  I need to make complete snapshots of hardware state from Python.  If I
-  have the time, I'll come back and fix the breakage.
-
-  @kgn
-  */
+/*
+ FIXME: Breakage of interface. This function returns data that is
+ supposed to be private.
+ 
+ I need to make complete snapshots of hardware state from Python.  If I
+ have the time, I'll come back and fix the breakage.
+ 
+ @kgn
+ */
 const tArray<cHardwareCPU_Thread> &cHardwareCPU::pyGetThreads(){
   return threads;
 }

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHardwareCPU.h	2005-11-17 21:14:48 UTC (rev 402)
@@ -1,9 +1,12 @@
-//////////////////////////////////////////////////////////////////////////////
-// Copyright (C) 1993 - 2004 California Institute of Technology             //
-//                                                                          //
-// Read the COPYING and README files, or contact 'avida at alife.org',         //
-// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
-//////////////////////////////////////////////////////////////////////////////
+/*
+ *  cHardwareCPU.h
+ *  Avida
+ *
+ *  Created by David on 11/17/05.
+ *  Copyright 2005 Michigan State University. All rights reserved.
+ *  Copyright 1999-2003 California Institute of Technology.
+ *
+ */
 
 #ifndef cHardwareCPU_h
 #define cHardwareCPU_h
@@ -11,10 +14,10 @@
 #include <iomanip>
 #include <vector>
 
-#ifndef DEFS_HH
+#ifndef defs_h
 #include "defs.h"
 #endif
-#ifndef CODE_LABEL_HH
+#ifndef cCodeLabel_h
 #include "cCodeLabel.h"
 #endif
 #ifndef nHardware_h
@@ -23,40 +26,28 @@
 #ifndef nHardwareCPU_h
 #include "nHardwareCPU.h"
 #endif
-#ifndef HEAD_CPU_HH
+#ifndef cHeadCPU_h
 #include "cHeadCPU.h"
 #endif
-#ifndef CPU_MEMORY_HH
+#ifndef cCPUMemory_h
 #include "cCPUMemory.h"
 #endif
-#ifndef CPU_STACK_HH
+#ifndef cCPUStack_h
 #include "cCPUStack.h"
 #endif
-#ifndef HARDWARE_BASE_HH
+#ifndef cHardwareBase_h
 #include "cHardwareBase.h"
 #endif
-#ifndef HARDWARE_CPU_THREAD_HH
+#ifndef cHardwareCPU_Thread_h
 #include "cHardwareCPU_Thread.h"
 #endif
-#ifndef STRING_HH
+#ifndef cString_h
 #include "cString.h"
 #endif
-#ifndef TARRAY_HH
+#ifndef tArray_h
 #include "tArray.h"
 #endif
 
-class cInstSet;
-class cInstLibBase;
-class cOrganism;
-class cMutation;
-class cHardwareCPU_Thread;
-
-#ifdef SINGLE_IO_BUFFER   // For Single IOBuffer vs IOBuffer for each Thread
-# define IO_THREAD 0
-#else
-# define IO_THREAD cur_thread
-#endif
-
 /**
  * Each organism may have a cHardwareCPU structure which keeps track of the
  * current status of all the components of the simulated hardware.
@@ -65,29 +56,27 @@
  **/
 
 class cCodeLabel; // access
-class cHeadCPU; // access
-class cCPUMemory; // aggregate
-class cCPUStack; // aggregate
 class cGenome;
-class cHardwareCPU_Thread; // access
+class cInjectGenotype;
 class cInstLibBase;
 class cInstLibCPU;
 class cInstruction;
 class cInstSet;
 class cMutation;
 class cOrganism;
-class cString; // aggregate
 template <class T> class tBuffer;
 template <class T> class tArray; // aggregate
 
 class cHardwareCPU : public cHardwareBase {
 public:
   typedef bool (cHardwareCPU::*tHardwareCPUMethod)();
+
 private:
   static cInstLibCPU *s_inst_slib;
   static cInstLibCPU *initInstLib(void);
+
   tHardwareCPUMethod *m_functions;
-private:
+
   cCPUMemory memory;          // Memory...
   cCPUStack global_stack;     // A stack that all threads share.
   int thread_time_used;
@@ -108,134 +97,94 @@
 
 public:
   cHardwareCPU(cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set);
-  explicit cHardwareCPU(const cHardwareCPU &);
+  explicit cHardwareCPU(const cHardwareCPU&);
   ~cHardwareCPU();
-  static cInstLibCPU *GetInstLib();
+  static cInstLibCPU* GetInstLib() { return s_inst_slib; }
   static cString GetDefaultInstFilename() { return "inst_lib.default"; }
-  static void WriteDefaultInstSet() { ; }
 
   void Reset();
   void SingleProcess();
-  bool SingleProcess_PayCosts(const cInstruction & cur_inst);
-  bool SingleProcess_ExecuteInst(const cInstruction & cur_inst);
-  void ProcessBonusInst(const cInstruction & inst);
-  void LoadGenome(const cGenome & new_genome);
+  void ProcessBonusInst(const cInstruction& inst);
 
+  
   // --------  Helper methods  --------
+  int GetType() const { return HARDWARE_TYPE_CPU_ORIGINAL; }  
   bool OK();
   void PrintStatus(std::ostream& fp);
 
 
-  // --------  Flag Accessors --------
-  bool GetMalActive() const   { return mal_active; }
-
   // --------  Stack Manipulation...  --------
-  inline void StackPush(int value);
-  inline int StackPop();
-  inline void StackFlip();
-  inline int GetStack(int depth=0, int stack_id=-1) const;
-  inline void StackClear();
-  inline void SwitchStack();
-  int GetActiveStackID() const { return threads[cur_thread].cur_stack; }
+  inline int GetStack(int depth=0, int stack_id=-1, int in_thread=-1) const;
 
 
   // --------  Head Manipulation (including IP)  --------
-  inline void SetActiveHead(const int new_head)
-  { threads[cur_thread].cur_head = (UCHAR) new_head; }
-
-  int GetCurHead() const { return threads[cur_thread].cur_head; }
-  const cHeadCPU & GetHead(int head_id) const
-    { return threads[cur_thread].heads[head_id]; }
-  cHeadCPU & GetHead(int head_id) { return threads[cur_thread].heads[head_id];}
-
-  const cHeadCPU & GetActiveHead() const { return GetHead(GetCurHead()); }
-  cHeadCPU & GetActiveHead() { return GetHead(GetCurHead()); }
-
-  void AdjustHeads();
-
-  inline const cHeadCPU & IP() const
-    { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
-  inline cHeadCPU & IP() { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
-
-
+  const cHeadCPU& GetHead(int head_id) const { return threads[cur_thread].heads[head_id]; }
+  cHeadCPU& GetHead(int head_id) { return threads[cur_thread].heads[head_id];}
+  const cHeadCPU& GetHead(int head_id, int thread) const { return threads[thread].heads[head_id]; }
+  cHeadCPU& GetHead(int head_id, int thread) { return threads[thread].heads[head_id];}
+  
+  const cHeadCPU& IP() const { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
+  cHeadCPU& IP() { return threads[cur_thread].heads[nHardware::HEAD_IP]; }
+  const cHeadCPU& IP(int thread) const { return threads[thread].heads[nHardware::HEAD_IP]; }
+  cHeadCPU& IP(int thread) { return threads[thread].heads[nHardware::HEAD_IP]; }
+  
+  
   // --------  Label Manipulation  -------
-  void ReadLabel(int max_size=nHardware::MAX_LABEL_SIZE);
-  const cCodeLabel & GetLabel() const 
-    { return threads[cur_thread].next_label; }
-  cCodeLabel & GetLabel() { return threads[cur_thread].next_label; }
-  const cCodeLabel & GetReadLabel() const
-    { return threads[cur_thread].read_label; }
-  cCodeLabel & GetReadLabel() { return threads[cur_thread].read_label; }
-
-
+  const cCodeLabel& GetLabel() const { return threads[cur_thread].next_label; }
+  cCodeLabel& GetLabel() { return threads[cur_thread].next_label; }
+  
+  
+  // --------  Memory Manipulation  --------
+  const cCPUMemory& GetMemory() const { return memory; }
+  cCPUMemory& GetMemory() { return memory; }
+  const cCPUMemory& GetMemory(int value) const { return memory;}
+  cCPUMemory& GetMemory(int value) { return memory; }
+  
+  
   // --------  Register Manipulation  --------
-  const int & Register(int reg_id) const { return threads[cur_thread].reg[reg_id]; }
-  int & Register(int reg_id) { return threads[cur_thread].reg[reg_id]; }
+  const int GetRegister(int reg_id) const { return threads[cur_thread].reg[reg_id]; }
+  int& GetRegister(int reg_id) { return threads[cur_thread].reg[reg_id]; }
 
-  // --------  Memory Manipulation  --------
-  inline const cCPUMemory & Memory() const { return memory; }
-  inline cCPUMemory & Memory() { return memory; }
-
+  
   // --------  Thread Manipulation  --------
   bool ForkThread(); // Adds a new thread based off of cur_thread.
   bool KillThread(); // Kill the current thread!
   inline void PrevThread(); // Shift the current thread in use.
   inline void NextThread();
   inline void SetThread(int value);
-
-  // --------  Tests  --------
-
+  cInjectGenotype* GetCurThreadOwner() { return NULL; } // @DMB - cHardwareCPU does not really implement cInjectGenotype yet
+  cInjectGenotype* GetThreadOwner(int in_thread) { return NULL; }
+  void SetThreadOwner(cInjectGenotype* in_genotype) { return; }
+  
+  
+  // --------  Parasite Stuff  --------
   int TestParasite() const;
+  bool InjectHost(const cCodeLabel& in_label, const cGenome& injection);
+  int InjectThread(const cCodeLabel& in_label, const cGenome& injection);
 
+  
   // --------  Accessors  --------
-  const cCPUMemory & GetMemory() const { return memory; }
-  cCPUMemory & GetMemory() { return memory; }
-  const cCPUMemory & GetMemory(int value) const { return memory;}
-  cCPUMemory & GetMemory(int value) { return memory; }
-
-  int GetThreadTimeUsed() const { return thread_time_used; }
   int GetNumThreads() const     { return threads.GetSize(); }
   int GetCurThread() const      { return cur_thread; }
   int GetCurThreadID() const    { return threads[cur_thread].GetID(); }
-
   int GetThreadDist() const {
     if (GetNumThreads() == 1) return 0;
-    return threads[0].heads[nHardware::HEAD_IP].GetPosition() -
-      threads[1].heads[nHardware::HEAD_IP].GetPosition();
+    return threads[0].heads[nHardware::HEAD_IP].GetPosition() - threads[1].heads[nHardware::HEAD_IP].GetPosition();
   }
 
-  // Complex label manipulation...
-  cHeadCPU FindLabel(int direction);
-  int FindLabel_Forward(const cCodeLabel & search_label,
-			  const cGenome & search_genome, int pos);
-  int FindLabel_Backward(const cCodeLabel & search_label,
-			  const cGenome & search_genome, int pos);
-  cHeadCPU FindLabel(const cCodeLabel & in_label, int direction);
-  cHeadCPU FindFullLabel(const cCodeLabel & in_label);
 
-  int GetType() const { return HARDWARE_TYPE_CPU_ORIGINAL; }
-  bool InjectHost(const cCodeLabel & in_label, const cGenome & injection);
-  int InjectThread(const cCodeLabel & in_label, const cGenome & injection);
-  void InjectCode(const cGenome & injection, const int line_num);
-  void InjectCodeThread(const cGenome & injection, const int line_num);
-  void Mutate(const int mut_point);
-  int PointMutate(const double mut_rate);
-
+  // --------  Mutation  --------
+  int PointMutate(const double mut_rate);  
   bool TriggerMutations(int trigger);
-  bool TriggerMutations(int trigger, cHeadCPU & cur_head);
-  bool TriggerMutations_ScopeGenome(const cMutation * cur_mut,
-        cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate);
-  bool TriggerMutations_ScopeLocal(const cMutation * cur_mut,
-        cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate);
-  int TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
-        cCPUMemory & target_memory, cHeadCPU & cur_head, const double rate);
-  void TriggerMutations_Body(int type, cCPUMemory & target_memory,
-			     cHeadCPU & cur_head);
-
-  void ReadInst(const int in_inst);
-
-  //void InitInstSet(const cString & filename, cInstSet & inst_set);
-
+  bool TriggerMutations(int trigger, cHeadCPU& cur_head);
+  
+  
+  // Non-Standard Methods
+  
+  int GetActiveStack(int stack_id) const { return threads[cur_thread].cur_stack; }
+  bool GetMalActive() const   { return mal_active; }
+  
+  
   /*
   FIXME: Breakage of interface. These functions return data that is
   supposed to be private.
@@ -245,38 +194,15 @@
 
   @kgn
   */
-  cCPUStack pyGetGlobalStack(){ return global_stack; }
-  int pyGetThreadTimeUsed(){ return thread_time_used; }
-  const tArray<cHardwareCPU_Thread> &pyGetThreads();
-  bool pyGetAdvanceIP(){ return advance_ip; }
+  cCPUStack pyGetGlobalStack() { return global_stack; }
+  int pyGetThreadTimeUsed() { return thread_time_used; }
+  const tArray<cHardwareCPU_Thread>& pyGetThreads();
+  bool pyGetAdvanceIP() { return advance_ip; }
 
+
 private:
- 
- /////////---------- Instruction Helpers ------------//////////
+  // ---------- Instruction Library -----------
 
-  int FindModifiedRegister(int default_register);
-  int FindModifiedHead(int default_head);
-  int FindComplementRegister(int base_reg);
-
-  void Fault(int fault_loc, int fault_type, cString fault_desc="");
-
-  bool Allocate_Necro(const int new_size);
-  bool Allocate_Random(const int old_size, const int new_size);
-  bool Allocate_Default(const int new_size);
-  bool Allocate_Main(const int allocated_size);
-
-  bool Divide_Main(const int divide_point, const int extra_lines=0, double mut_multiplier=1);
-
-  bool Divide_CheckViable(const int child_size, const int parent_size);
-  void Divide_DoMutations(double mut_multiplier=1);
-  void Divide_TestFitnessMeasures();
-
-  bool HeadCopy_ErrorCorrect(double reduction);
-  bool Inst_HeadDivideMut(double mut_multiplier=1);
-
-public:
-  /////////---------- Instruction Library ------------//////////
-
   // Flow Control
   bool Inst_If0();
   bool Inst_IfEqu();
@@ -472,55 +398,76 @@
   bool Inst_HeadDivide0_01();
   bool Inst_HeadDivide0_001();
 
+  //// Placebo ////
+  bool Inst_Skip();
 
-  // Direct Matching Templates
 
-  bool Inst_DMJumpF();
-  //bool Inst_DMJumpB();
-  //bool Inst_DMCall();
-  //bool Inst_DMSearchF();
-  //bool Inst_DMSearchB();
+  // Internal Implementation
 
-  // Relative Addressed Jumps
-
-  //bool Inst_REJumpF();
-  //bool Inst_REJumpB();
-
-  // Absoulte Addressed Jumps
-
-  //bool Inst_ABSJump();
-
-  // Biologically inspired reproduction
-  //bool Inst_BCAlloc();
-  //bool Inst_BCopy();
-  //bool Inst_BDivide();
-private:
-  bool Inst_BCopy_Main(double mut_prob); // Internal called by all BCopy's
-public:
-  // Bio Error Correction
-  //bool Inst_BCopyDiv2();
-  //bool Inst_BCopyDiv3();
-  //bool Inst_BCopyDiv4();
-  //bool Inst_BCopyDiv5();
-  //bool Inst_BCopyDiv6();
-  //bool Inst_BCopyDiv7();
-  //bool Inst_BCopyDiv8();
-  //bool Inst_BCopyDiv9();
-  //bool Inst_BCopyDiv10();
-  //bool Inst_BCopyPow2();
-  //bool Inst_BIfNotCopy();
-  //bool Inst_BIfCopy();
-
-
-  //// Placebo ////
-  bool Inst_Skip();
+  bool SingleProcess_PayCosts(const cInstruction & cur_inst);
+  bool SingleProcess_ExecuteInst(const cInstruction & cur_inst);
+  
+  // --------  Stack Manipulation...  --------
+  inline void StackPush(int value);
+  inline int StackPop();
+  inline void StackFlip();
+  inline void StackClear();
+  inline void SwitchStack();
+  
+  
+  // --------  Head Manipulation (including IP)  --------
+  cHeadCPU& GetActiveHead() { return threads[cur_thread].heads[threads[cur_thread].cur_head]; }
+  void AdjustHeads();
+  
+  
+  // --------  Label Manipulation  -------
+  void ReadLabel(int max_size=nHardware::MAX_LABEL_SIZE);
+  cHeadCPU FindLabel(int direction);
+  int FindLabel_Forward(const cCodeLabel & search_label, const cGenome& search_genome, int pos);
+  int FindLabel_Backward(const cCodeLabel & search_label, const cGenome& search_genome, int pos);
+  cHeadCPU FindLabel(const cCodeLabel & in_label, int direction);
+  cHeadCPU FindFullLabel(const cCodeLabel & in_label);
+  const cCodeLabel& GetReadLabel() const { return threads[cur_thread].read_label; }
+  cCodeLabel& GetReadLabel() { return threads[cur_thread].read_label; }
+  
+  
+  bool TriggerMutations_ScopeGenome(const cMutation* cur_mut,
+                                    cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);
+  bool TriggerMutations_ScopeLocal(const cMutation* cur_mut,
+                                   cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);
+  int TriggerMutations_ScopeGlobal(const cMutation* cur_mut, 
+                                   cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate);
+  void TriggerMutations_Body(int type, cCPUMemory& target_memory, cHeadCPU& cur_head);
+  
+  
+  // ---------- Instruction Helpers -----------
+  int FindModifiedRegister(int default_register);
+  int FindModifiedHead(int default_head);
+  int FindComplementRegister(int base_reg);
+  
+  void Fault(int fault_loc, int fault_type, cString fault_desc="");
+  
+  bool Allocate_Necro(const int new_size);
+  bool Allocate_Random(const int old_size, const int new_size);
+  bool Allocate_Default(const int new_size);
+  bool Allocate_Main(const int allocated_size);
+  
+  bool Divide_Main(const int divide_point, const int extra_lines=0, double mut_multiplier=1);
+  bool Divide_CheckViable(const int child_size, const int parent_size);
+  void Divide_DoMutations(double mut_multiplier=1);
+  void Divide_TestFitnessMeasures();
+  void Mutate(const int mut_point);
+  
+  void InjectCode(const cGenome& injection, const int line_num);
+  void InjectCodeThread(const cGenome& injection, const int line_num);
+  
+  bool HeadCopy_ErrorCorrect(double reduction);
+  bool Inst_HeadDivideMut(double mut_multiplier=1);
+  
+  void ReadInst(const int in_inst);
 };
 
 
-//////////////////
-//  cHardwareCPU
-//////////////////
-
 inline void cHardwareCPU::NextThread()
 {
   cur_thread++;
@@ -570,8 +517,9 @@
   }
 }
 
-inline int cHardwareCPU::GetStack(int depth, int stack_id) const
+inline int cHardwareCPU::GetStack(int depth, int stack_id, int in_thread) const
 {
+  // @DMB - warning: cHardwareCPU::GetStack ignores in_thread
   int value = 0;
 
   if (stack_id == -1) stack_id = threads[cur_thread].cur_stack;

Modified: development/source/cpu/cHardwareManager.cc
===================================================================
--- development/source/cpu/cHardwareManager.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHardwareManager.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -45,41 +45,16 @@
 			default_filename = "unknown";
   }
   
-  if (filename == "")
-	{
+  if (filename == "") {
     filename = default_filename;
-    cerr << "Warning: No instruction set specified; using default '"
-    << filename << "'." << endl;
+    cerr << "Warning: No instruction set specified, using default '" << filename << "'." << endl;
   }
   
   cInitFile file(filename);
   
-  // If we could not open the instruction set what to do?
-  if (file.IsOpen() == false)
-	{
-    
-    // If this is the default filename, write the file and try again.
-    if (filename == default_filename)
-		{
-			switch (m_type)
-			{
-				case HARDWARE_TYPE_CPU_ORIGINAL:
-					cHardwareCPU::WriteDefaultInstSet();
-					break;
-				case HARDWARE_TYPE_CPU_4STACK:
-					cHardware4Stack::WriteDefaultInstSet();
-					break;
-				case HARDWARE_TYPE_CPU_SMT:
-					cHardwareSMT::WriteDefaultInstSet();
-			}
-    }
-    // If this is not the default filename, give and error and stop.
-    else
-		{
-      cerr << "Error: Could not open instruction set '" << filename
-      << "'.  Exiting..." << endl;
-      exit(1);
-    }
+  if (file.IsOpen() == false) {
+    cerr << "Error: Could not open instruction set '" << filename << "'.  Exiting..." << endl;
+    exit(1);
   }
   
   file.Load();

Modified: development/source/cpu/cHardwareSMT.cc
===================================================================
--- development/source/cpu/cHardwareSMT.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHardwareSMT.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -29,14 +29,10 @@
 
 using namespace std;
 
-///////////////
-//  cHardwareSMT
-///////////////
+tInstLib<cHardwareSMT::tMethod>* cHardwareSMT::s_inst_slib = cHardwareSMT::initInstLib();
 
-cInstLibBase* cHardwareSMT::GetInstLib(){ return s_inst_slib; }
-
-tInstLib<cHardwareSMT::tMethod> *cHardwareSMT::s_inst_slib = cHardwareSMT::initInstLib();
-tInstLib<cHardwareSMT::tMethod> *cHardwareSMT::initInstLib(void){
+tInstLib<cHardwareSMT::tMethod>* cHardwareSMT::initInstLib(void)
+{
   struct cNOPEntry {
     cNOPEntry(const cString &name, int nop_mod):name(name), nop_mod(nop_mod){}
     cString name;
@@ -114,14 +110,14 @@
 	const cInstruction error(255);
 	const cInstruction def(0);
 	
-  tInstLib<cHardwareSMT::tMethod> *inst_lib =
+  tInstLib<cHardwareSMT::tMethod>* inst_lib =
     new tInstLib<cHardwareSMT::tMethod>(n_size, f_size, n_names, f_names, nop_mods, functions, error, def);
 	
   return inst_lib;
 }
 
-cHardwareSMT::cHardwareSMT(cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set)
-: cHardwareBase(world, in_organism, in_inst_set), m_mem_array(1),
+cHardwareSMT::cHardwareSMT(cWorld* world, cOrganism* in_organism, cInstSet* in_m_inst_set)
+: cHardwareBase(world, in_organism, in_m_inst_set), m_mem_array(1),
 m_mem_lbls(Pow(nHardwareSMT::NUM_NOPS, nHardwareSMT::MAX_MEMSPACE_LABEL) / nHardwareSMT::MEM_LBLS_HASH_FACTOR)
 {
   m_functions = s_inst_slib->GetFunctions();
@@ -153,13 +149,13 @@
 	
 #ifdef INSTRUCTION_COSTS
   // instruction cost arrays
-  const int num_inst_cost = GetNumInst();
+  const int num_inst_cost = m_inst_set->GetSize();
   inst_cost.Resize(num_inst_cost);
   inst_ft_cost.Resize(num_inst_cost);
 	
   for (int i = 0; i < num_inst_cost; i++) {
-    inst_cost[i] = GetInstSet().GetCost(cInstruction(i));
-    inst_ft_cost[i] = GetInstSet().GetFTCost(cInstruction(i));
+    inst_cost[i] = m_inst_set->GetCost(cInstruction(i));
+    inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
   }
 #endif	
 }
@@ -237,18 +233,18 @@
   }
 	
   // Next, look at the per use cost
-  if ( GetInstSet().GetCost(cur_inst) > 0 ) {
+  if ( m_inst_set->GetCost(cur_inst) > 0 ) {
     if ( inst_cost[cur_inst.GetOp()] > 1 ){  // if isn't paid off (>1)
       inst_cost[cur_inst.GetOp()]--;         // dec cost
       return false;
     } else {                                 // else, reset cost array
-      inst_cost[cur_inst.GetOp()] = GetInstSet().GetCost(cur_inst);
+      inst_cost[cur_inst.GetOp()] = m_inst_set->GetCost(cur_inst);
     }
   }
 	
   // Prob of exec
-  if ( GetInstSet().GetProbFail(cur_inst) > 0.0 ){
-    return !( m_world->GetRandom().P(GetInstSet().GetProbFail(cur_inst)) );
+  if ( m_inst_set->GetProbFail(cur_inst) > 0.0 ){
+    return !( m_world->GetRandom().P(m_inst_set->GetProbFail(cur_inst)) );
   }
 #endif
   return true;
@@ -263,11 +259,11 @@
   
 #ifdef EXECUTION_ERRORS
   // If there is an execution error, execute a random instruction.
-  if (organism->TestExeErr()) actual_inst = GetInstSet().GetRandomInst();
+  if (organism->TestExeErr()) actual_inst = m_inst_set->GetRandomInst();
 #endif /* EXECUTION_ERRORS */
 	
   // Get a pointer to the corrisponding method...
-  int inst_idx = GetInstSet().GetLibFunctionIndex(actual_inst);
+  int inst_idx = m_inst_set->GetLibFunctionIndex(actual_inst);
   
   // Mark the instruction as executed
   IP().FlagExecuted() = true;
@@ -447,17 +443,17 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
 		
-    if (inst_set->IsNop(search_genome[pos])) {
+    if (m_inst_set->IsNop(search_genome[pos])) {
       // Find the start and end of the label we're in the middle of.
 			
       int start_pos = pos;
       int end_pos = pos + 1;
       while (start_pos > search_start &&
-						 inst_set->IsNop( search_genome[start_pos - 1] )) {
+						 m_inst_set->IsNop( search_genome[start_pos - 1] )) {
 				start_pos--;
       }
       while (end_pos < search_genome.GetSize() &&
-						 inst_set->IsNop( search_genome[end_pos] )) {
+						 m_inst_set->IsNop( search_genome[end_pos] )) {
 				end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -471,7 +467,7 @@
 				int matches;
 				for (matches = 0; matches < label_size; matches++) {
 					if (search_label[matches] !=
-							inst_set->GetNopMod( search_genome[offset + matches] )) {
+							m_inst_set->GetNopMod( search_genome[offset + matches] )) {
 						break;
 					}
 				}
@@ -527,16 +523,16 @@
     // If we are within a label, rewind to the beginning of it and see if
     // it has the proper sub-label that we're looking for.
 		
-    if (inst_set->IsNop( search_genome[pos] )) {
+    if (m_inst_set->IsNop( search_genome[pos] )) {
       // Find the start and end of the label we're in the middle of.
 			
       int start_pos = pos;
       int end_pos = pos + 1;
-      while (start_pos > 0 && inst_set->IsNop(search_genome[start_pos - 1])) {
+      while (start_pos > 0 && m_inst_set->IsNop(search_genome[start_pos - 1])) {
 				start_pos--;
       }
       while (end_pos < search_start &&
-						 inst_set->IsNop(search_genome[end_pos])) {
+						 m_inst_set->IsNop(search_genome[end_pos])) {
 				end_pos++;
       }
       int test_size = end_pos - start_pos;
@@ -549,7 +545,7 @@
 				int matches;
 				for (matches = 0; matches < label_size; matches++) {
 					if (search_label[matches] !=
-							inst_set->GetNopMod(search_genome[offset + matches])) {
+							m_inst_set->GetNopMod(search_genome[offset + matches])) {
 						break;
 					}
 				}
@@ -604,8 +600,8 @@
 		
     int i;
     for (i = 0; i < in_label.GetSize(); i++) {
-      if (!inst_set->IsNop(temp_head.GetInst()) ||
-					in_label[i] != inst_set->GetNopMod(temp_head.GetInst())) {
+      if (!m_inst_set->IsNop(temp_head.GetInst()) ||
+					in_label[i] != m_inst_set->GetNopMod(temp_head.GetInst())) {
 				break;
       }
     }
@@ -631,19 +627,19 @@
 	
   while (temp_head.InMemory()) {
     // If we are not in a label, jump to the next checkpoint...
-    if (inst_set->IsNop(temp_head.GetInst())) {
+    if (m_inst_set->IsNop(temp_head.GetInst())) {
       temp_head.AbsJump(in_label.GetSize());
       continue;
     }
 		
     // Otherwise, rewind to the begining of this label...
-    while (!(temp_head.AtFront()) && inst_set->IsNop(temp_head.GetInst(-1)))
+    while (!(temp_head.AtFront()) && m_inst_set->IsNop(temp_head.GetInst(-1)))
       temp_head.AbsJump(-1);
 		
     // Calculate the size of the label being checked, and make sure they
     // are equal.		
     int checked_size = 0;
-    while (inst_set->IsNop(temp_head.GetInst(checked_size))) {
+    while (m_inst_set->IsNop(temp_head.GetInst(checked_size))) {
       checked_size++;
     }
     if (checked_size != in_label.GetSize()) {
@@ -655,8 +651,8 @@
     int j;
     bool label_match = true;
     for (j = 0; j < in_label.GetSize(); j++) {
-      if (!inst_set->IsNop(temp_head.GetInst(j)) ||
-					in_label[j] != inst_set->GetNopMod(temp_head.GetInst(j))) {
+      if (!m_inst_set->IsNop(temp_head.GetInst(j)) ||
+					in_label[j] != m_inst_set->GetNopMod(temp_head.GetInst(j))) {
 				temp_head.AbsJump(in_label.GetSize() + 1);
 				label_match = false;
 				break;
@@ -748,63 +744,6 @@
 {
   // @DMB - Need to discuss how InjectHost should work with extensible memory spaces...
   return false;
-  
-  // Make sure the genome will be below max size after injection.	
-  // xxxTEMPORARYxxx - we should have this match injection templates.  For now it simply 
-	// FIND THE FIRST EMPTY MEMORY SPACE
-  int target_mem_space = 0;
-  for (; target_mem_space < m_mem_array.GetSize(); target_mem_space++)
-	{
-		if(isEmpty(target_mem_space))
-		{
-			break;
-		}
-	}
-  
-  if (target_mem_space == m_mem_array.GetSize())
-	{
-		return false;
-	}
-	
-  assert(target_mem_space >=0 && target_mem_space < m_mem_array.GetSize());
-  
-  if(ForkThread()) {
-    // Inject the new code
-    cCPUMemory oldcode = m_mem_array[target_mem_space];
-    m_mem_array[target_mem_space] = inject_code;
-    m_mem_array[target_mem_space].Resize(inject_code.GetSize() + oldcode.GetSize());
-		
-    // Copies previous instructions to the end of the injected code.
-    // Is there a faster way to do this?? -law
-    for(int x=0; x<oldcode.GetSize(); x++)
-      m_mem_array[target_mem_space][inject_code.GetSize()+x] = oldcode[x];
-		
-    // Set instruction flags on the injected code
-    for (int i = 0; i < inject_code.GetSize(); i++) {
-      m_mem_array[target_mem_space].FlagInjected(i) = true;
-    }
-    organism->GetPhenotype().IsModified() = true;
-    
-    // Adjust all of the heads to take into account the new mem size.
-    
-    m_cur_thread=GetNumThreads()-1;
-    
-    for(int i=0; i<m_cur_thread; i++) {
-      for(int j=0; j < nHardware::NUM_HEADS; j++) {
-				if(m_threads[i].heads[j].GetMemSpace()==target_mem_space)
-					m_threads[i].heads[j].Jump(inject_code.GetSize());
-      }
-    }
-    
-    for (int i=0; i < nHardware::NUM_HEADS; i++) {    
-      GetHead(i).Reset(target_mem_space, this);
-    }
-    for (int i=0; i < nHardwareSMT::NUM_LOCAL_STACKS; i++) {
-      Stack(i).Clear();
-    }
-  }
-	
-  return true; // (inject succeeds!)
 }
 
 void cHardwareSMT::Mutate(int mut_point)
@@ -812,7 +751,7 @@
   // Test if trying to mutate outside of genome...
   assert(mut_point >= 0 && mut_point < m_mem_array[0].GetSize());
 	
-  m_mem_array[0][mut_point] = GetRandomInst();
+  m_mem_array[0][mut_point] = m_inst_set->GetRandomInst();
   m_mem_array[0].FlagMutated(mut_point) = true;
   m_mem_array[0].FlagPointMut(mut_point) = true;
   organism->CPUStats().mut_stats.point_mut_count++;
@@ -845,7 +784,7 @@
   return TriggerMutations(trigger, IP());
 }
 
-bool cHardwareSMT::TriggerMutations(int trigger, cHeadMultiMem& cur_head)
+bool cHardwareSMT::TriggerMutations(int trigger, cHeadCPU& cur_head)
 {
   // Collect information about mutations from the organism.
   cLocalMutations& mut_info = organism->GetLocalMutations();
@@ -897,8 +836,8 @@
   return has_mutation;
 }
 
-bool cHardwareSMT::TriggerMutations_ScopeGenome(const cMutation * cur_mut,
-                                                cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate)
+bool cHardwareSMT::TriggerMutations_ScopeGenome(const cMutation* cur_mut,
+                                                cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate)
 {
   // The rate we have stored indicates the probability that a single
   // mutation will occur anywhere in the genome.
@@ -906,7 +845,7 @@
   if (m_world->GetRandom().P(rate) == true) {
     // We must create a temporary head and use it to randomly determine the
     // position in the genome to be mutated.
-    cHeadMultiMem tmp_head(cur_head);
+    cHeadCPU tmp_head(cur_head);
     tmp_head.AbsSet(m_world->GetRandom().GetUInt(target_memory.GetSize()));
     TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
     return true;
@@ -914,8 +853,8 @@
   return false;
 }
 
-bool cHardwareSMT::TriggerMutations_ScopeLocal(const cMutation * cur_mut,
-                                               cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate)
+bool cHardwareSMT::TriggerMutations_ScopeLocal(const cMutation* cur_mut,
+                                               cCPUMemory& target_memory, cHeadCPU& cur_head, const double rate)
 {
   // The rate we have stored is the probability for a mutation at this single
   // position in the genome.
@@ -928,7 +867,7 @@
 }
 
 int cHardwareSMT::TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
-                                               cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate)
+                                               cCPUMemory & target_memory, cHeadCPU& cur_head, const double rate)
 {
   // The probability we have stored is per-site, so we can pull a random
   // number from a binomial distribution to determine the number of mutations
@@ -939,7 +878,7 @@
 	
   if (num_mut > 0) {
     for (int i = 0; i < num_mut; i++) {
-      cHeadMultiMem tmp_head(cur_head);
+      cHeadCPU tmp_head(cur_head);
       tmp_head.AbsSet(m_world->GetRandom().GetUInt(target_memory.GetSize()));
       TriggerMutations_Body(cur_mut->GetType(), target_memory, tmp_head);
     }
@@ -948,14 +887,13 @@
   return num_mut;
 }
 
-void cHardwareSMT::TriggerMutations_Body(int type, cCPUMemory & target_memory,
-                                         cHeadMultiMem & cur_head)
+void cHardwareSMT::TriggerMutations_Body(int type, cCPUMemory & target_memory, cHeadCPU& cur_head)
 {
   const int pos = cur_head.GetPosition();
 	
   switch (type) {
 		case nMutation::TYPE_POINT:
-			target_memory[pos] = GetRandomInst();
+			target_memory[pos] = m_inst_set->GetRandomInst();
 			target_memory.FlagMutated(pos) = true;
 			break;
 		case nMutation::TYPE_INSERT:
@@ -972,25 +910,13 @@
 
 void cHardwareSMT::ReadInst(const int in_inst)
 {
-  if (inst_set->IsNop( cInstruction(in_inst) )) {
+  if (m_inst_set->IsNop( cInstruction(in_inst) )) {
     GetReadLabel().AddNop(in_inst);
   } else {
     GetReadLabel().Clear();
   }
 }
 
-
-void cHardwareSMT::AdjustHeads()
-{
-  for (int i = 0; i < GetNumThreads(); i++) {
-    for (int j = 0; j < nHardware::NUM_HEADS; j++) {
-      m_threads[i].heads[j].Adjust();
-    }
-  }
-}
-
-
-
 // This function looks at the current position in the info of a creature,
 // and sets the next_label to be the sequence of nops which follows.  The
 // instruction pointer is left on the last line of the label found.
@@ -1002,11 +928,11 @@
 	
   GetLabel().Clear();
 	
-  while (inst_set->IsNop(inst_ptr->GetNextInst()) &&
+  while (m_inst_set->IsNop(inst_ptr->GetNextInst()) &&
 				 (count < max_size)) {
     count++;
     inst_ptr->Advance();
-    GetLabel().AddNop(inst_set->GetNopMod(inst_ptr->GetInst()));
+    GetLabel().AddNop(m_inst_set->GetNopMod(inst_ptr->GetInst()));
 		
     // If this is the first line of the template, mark it executed.
     if (GetLabel().GetSize() <=	m_world->GetConfig().MAX_LABEL_EXE_SIZE.Get()) {
@@ -1081,9 +1007,9 @@
 {
   assert(default_stack < nHardwareSMT::NUM_STACKS);  // Stack ID too high.
 	
-  if (GetInstSet().IsNop(IP().GetNextInst())) {
+  if (m_inst_set->IsNop(IP().GetNextInst())) {
     IP().Advance();
-    default_stack = GetInstSet().GetNopMod(IP().GetInst());
+    default_stack = m_inst_set->GetNopMod(IP().GetInst());
     IP().FlagExecuted() = true;
   }
   return default_stack;
@@ -1093,9 +1019,9 @@
 {
   assert(default_stack < nHardwareSMT::NUM_STACKS);  // Stack ID too high.
 	
-  if (GetInstSet().IsNop(IP().GetNextInst())) {
+  if (m_inst_set->IsNop(IP().GetNextInst())) {
     IP().Advance();
-    default_stack = GetInstSet().GetNopMod(IP().GetInst());
+    default_stack = m_inst_set->GetNopMod(IP().GetInst());
     IP().FlagExecuted() = true;
   } else {
     default_stack = FindNextStack(default_stack);
@@ -1107,9 +1033,9 @@
 {
   assert(default_stack < nHardwareSMT::NUM_STACKS);  // Stack ID too high.
 	
-  if (GetInstSet().IsNop(IP().GetNextInst())) {
+  if (m_inst_set->IsNop(IP().GetNextInst())) {
     IP().Advance();
-    default_stack = GetInstSet().GetNopMod(IP().GetInst());
+    default_stack = m_inst_set->GetNopMod(IP().GetInst());
     IP().FlagExecuted() = true;
   } else {
     default_stack = FindPreviousStack(default_stack);
@@ -1121,9 +1047,9 @@
 {
   assert(default_stack < nHardwareSMT::NUM_STACKS);  // Stack ID too high.
 	
-  if (GetInstSet().IsNop(IP().GetNextInst())) {
+  if (m_inst_set->IsNop(IP().GetNextInst())) {
     IP().Advance();
-    default_stack = GetInstSet().GetNopMod(IP().GetInst());
+    default_stack = m_inst_set->GetNopMod(IP().GetInst());
     IP().FlagExecuted() = true;
   } else {
     default_stack = FindPreviousStack(default_stack);
@@ -1135,9 +1061,9 @@
 {
   assert(default_head < nHardware::NUM_HEADS); // Head ID too high.
 	
-  if (GetInstSet().IsNop(IP().GetNextInst())) {
+  if (m_inst_set->IsNop(IP().GetNextInst())) {
     IP().Advance();    
-    int nop_head = GetInstSet().GetNopMod(IP().GetInst());
+    int nop_head = m_inst_set->GetNopMod(IP().GetInst());
     if (nop_head < nHardware::NUM_HEADS) default_head = nop_head;
     IP().FlagExecuted() = true;
   }
@@ -1232,14 +1158,14 @@
   // Divide Mutations
   if (organism->TestDivideMut()) {
     const UINT mut_line = m_world->GetRandom().GetUInt(child_genome.GetSize());
-    child_genome[mut_line] = GetRandomInst();
+    child_genome[mut_line] = m_inst_set->GetRandomInst();
     cpu_stats.mut_stats.divide_mut_count++;
   }
 	
   // Divide Insertions
   if (organism->TestDivideIns() && child_genome.GetSize() < MAX_CREATURE_SIZE){
     const UINT mut_line = m_world->GetRandom().GetUInt(child_genome.GetSize() + 1);
-    child_genome.Insert(mut_line, GetRandomInst());
+    child_genome.Insert(mut_line, m_inst_set->GetRandomInst());
     cpu_stats.mut_stats.divide_insert_mut_count++;
   }
 	
@@ -1259,7 +1185,7 @@
     if( num_mut > 0 ){
       for (int i = 0; i < num_mut; i++) {
 				int site = m_world->GetRandom().GetUInt(child_genome.GetSize());
-				child_genome[site]=GetRandomInst();
+				child_genome[site] = m_inst_set->GetRandomInst();
 				cpu_stats.mut_stats.div_mut_count++;
       }
     }
@@ -1285,7 +1211,7 @@
       qsort( (void*)mut_sites, num_mut, sizeof(int), &IntCompareFunction );
       // Actually do the mutations (in reverse sort order)
       for(int i = num_mut-1; i >= 0; i--) {
-				child_genome.Insert(mut_sites[i], GetRandomInst());
+				child_genome.Insert(mut_sites[i], m_inst_set->GetRandomInst());
 				cpu_stats.mut_stats.insert_mut_count++;
       }
     }
@@ -1314,7 +1240,7 @@
   if (organism->GetParentMutProb() > 0) {
     for (int i = 0; i < m_mem_array[0].GetSize(); i++) {
       if (organism->TestParentMut()) {
-				m_mem_array[0][i] = GetRandomInst();
+				m_mem_array[0][i] = m_inst_set->GetRandomInst();
 				cpu_stats.mut_stats.parent_mut_line_count++;
       }
     }
@@ -1341,13 +1267,13 @@
   // Divide Mutations
   if (organism->TestDivideMut()) {
     const UINT mut_line = m_world->GetRandom().GetUInt(injected_code.GetSize());
-    injected_code[mut_line] = GetRandomInst();
+    injected_code[mut_line] = m_inst_set->GetRandomInst();
   }
 	
   // Divide Insertions
   if (organism->TestDivideIns() && injected_code.GetSize() < MAX_CREATURE_SIZE){
     const UINT mut_line = m_world->GetRandom().GetUInt(injected_code.GetSize() + 1);
-    injected_code.Insert(mut_line, GetRandomInst());
+    injected_code.Insert(mut_line, m_inst_set->GetRandomInst());
   }
 	
   // Divide Deletions
@@ -1364,7 +1290,7 @@
     if( num_mut > 0 ){
       for (int i = 0; i < num_mut; i++) {
 				int site = m_world->GetRandom().GetUInt(injected_code.GetSize());
-				injected_code[site]=GetRandomInst();
+				injected_code[site] = m_inst_set->GetRandomInst();
       }
     }
   }
@@ -1389,7 +1315,7 @@
       qsort( (void*)mut_sites, num_mut, sizeof(int), &IntCompareFunction );
       // Actually do the mutations (in reverse sort order)
       for(int i = num_mut-1; i >= 0; i--) {
-				injected_code.Insert(mut_sites[i], GetRandomInst());
+				injected_code.Insert(mut_sites[i], m_inst_set->GetRandomInst());
       }
     }
   }
@@ -1415,7 +1341,7 @@
   if (organism->GetParentMutProb() > 0) {
     for (int i = 0; i < m_mem_array[0].GetSize(); i++) {
       if (organism->TestParentMut()) {
-				m_mem_array[0][i] = GetRandomInst();
+				m_mem_array[0][i] = m_inst_set->GetRandomInst();
       }
     }
   }
@@ -1513,7 +1439,7 @@
 #ifdef INSTRUCTION_COSTS
   // reset first time instruction costs
   for (int i = 0; i < inst_ft_cost.GetSize(); i++) {
-    inst_ft_cost[i] = GetInstSet().GetFTCost(cInstruction(i));
+    inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
   }
 #endif
 	
@@ -1560,25 +1486,7 @@
   return true;
 }
 
-cString cHardwareSMT::GetActiveStackID(int stackID) const
-{
-  if(stackID == nHardwareSMT::STACK_AX)
-    return "AX";
-  else if(stackID == nHardwareSMT::STACK_BX)
-    return "BX";
-  else if(stackID == nHardwareSMT::STACK_CX)
-    return "CX";
-  else if(stackID == nHardwareSMT::STACK_DX)
-    return "DX";
-  else
-    return "";
-}
 
-
-//////////////////////////
-// And the instructions...
-//////////////////////////
-
 //6
 bool cHardwareSMT::Inst_ShiftR()
 {
@@ -1784,7 +1692,7 @@
   // Mutations only occur on the read, for the moment.
   int read_inst = 0;
   if (organism->TestCopyMut()) {
-    read_inst = GetRandomInst().GetOp();
+    read_inst = m_inst_set->GetRandomInst().GetOp();
     cpu_stats.mut_stats.copy_mut_count++;  // @CAO, hope this is good!
   } else {
     read_inst = GetHead(head_id).GetInst().GetOp();
@@ -1819,7 +1727,7 @@
   active_head.Adjust();
 	
   int value = Stack(src).Pop();
-  if (value < 0 || value >= GetNumInst()) value = nHardwareSMT::NOPX;
+  if (value < 0 || value >= m_inst_set->GetSize()) value = nHardwareSMT::NOPX;
 	
   active_head.SetInst(cInstruction(value));
   active_head.FlagCopied() = true;
@@ -1845,7 +1753,7 @@
   // Do mutations.
   cInstruction read_inst = read_head.GetInst();
   if (organism->TestCopyMut()) {
-    read_inst = GetRandomInst();
+    read_inst = m_inst_set->GetRandomInst();
     cpu_stats.mut_stats.copy_mut_count++; 
     write_head.FlagMutated() = true;
     write_head.FlagCopyMut() = true;
@@ -2094,50 +2002,7 @@
   return true;
 }
 
-int cHardwareSMT::FindFirstEmpty()
-{
-  bool OK = true;
-  const int current_mem_space = IP().GetMemSpace();
-	
-  for(int x = 1; x < m_mem_array.GetSize(); x++)
-	{
-		OK = true;
-		
-		int index = (current_mem_space + x) % m_mem_array.GetSize();
-		
-		for(int y = 0; y < m_mem_array[index].GetSize(); y++) {
-			if(m_mem_array[index][y].GetOp() >= nHardwareSMT::NUM_NOPS) {
-        OK = false;
-        break;
-      }
-		}
-    if (!OK) break;
-    
-		for(int y = 0; y < GetNumThreads(); y++) {
-			for(int z=0; z<nHardware::NUM_HEADS; z++) {
-	      if(m_threads[y].heads[z].GetMemSpace() == index) {
-					OK = false;
-          break;
-        }
-	    }
-		}
 
-		if(OK) return index;
-	}
-  
-  return -1;
-}
-
-bool cHardwareSMT::isEmpty(int mem_space_used)
-{
-  // @DMB - shouldn't this just be return false if GetSize() != 1
-  for(int x = 0; x < m_mem_array[mem_space_used].GetSize(); x++) {
-		if(m_mem_array[mem_space_used][x].GetOp() >= nHardwareSMT::NUM_NOPS)
-			return false;
-	}
-  return true;
-}
-
 // The inject instruction can be used instead of a divide command, paired
 // with an allocate.  Note that for an inject to work, one needs to have a
 // broad range for sizes allowed to be allocated.

Modified: development/source/cpu/cHardwareSMT.h
===================================================================
--- development/source/cpu/cHardwareSMT.h	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHardwareSMT.h	2005-11-17 21:14:48 UTC (rev 402)
@@ -7,51 +7,45 @@
  *
  */
 
-#ifndef HARDWARE_SMT_H
-#define HARDWARE_SMT_H
+#ifndef cHardwareSMT_h
+#define cHardwareSMT_h
 
 #include <iomanip>
 
-#ifndef CPU_MEMORY_HH
+#ifndef cCPUMemory_h
 #include "cCPUMemory.h"
 #endif
-#ifndef CPU_STACK_HH
+#ifndef cCPUStack_h
 #include "cCPUStack.h"
 #endif
-#ifndef DEFS_HH
+#ifndef defs_h
 #include "defs.h"
 #endif
-#ifndef HEAD_MULTI_MEM_HH
+#ifndef cHeadMultiMem_h
 #include "cHeadMultiMem.h"
 #endif
-#ifndef HARDWARE_BASE_HH
+#ifndef cHardwareBase_h
 #include "cHardwareBase.h"
 #endif
-#ifndef HARDWARE_SMT_CONSTANTS_H
+#ifndef nHardwareSMT_h
 #include "nHardwareSMT.h"
 #endif
-#ifndef HARDWARE_SMT_THREAD_H
+#ifndef cHardwareSMT_Thread_h
 #include "cHardwareSMT_Thread.h"
 #endif
-#ifndef STRING_HH
+#ifndef cString_h
 #include "cString.h"
 #endif
-#ifndef TARRAY_HH
+#ifndef tArray_h
 #include "tArray.h"
 #endif
-#ifndef TINSTLIB_H
+#ifndef tInstLib_h
 #include "tInstLib.h"
 #endif
-#ifndef THASH_TABLE_HH
+#ifndef tHashTable_h
 #include "tHashTable.h"
 #endif
 
-/**
-* Each organism may have a cHardwareSMT structure which keeps track of the
- * current status of all the components of the simulated hardware.
- *
- * @see cHardwareSMT_Thread, cCPUStack, cCPUMemory, cInstSet
- **/
 
 class cInstSet;
 class cInstLibBase;
@@ -69,11 +63,13 @@
 class cHardwareSMT : public cHardwareBase {
 public:
   typedef bool (cHardwareSMT::*tMethod)();
+
 private:
   static tInstLib<cHardwareSMT::tMethod>* s_inst_slib;
   static tInstLib<cHardwareSMT::tMethod>* initInstLib(void);
+
   tMethod* m_functions;
-private:
+
   // Stacks
   cCPUStack m_global_stacks[nHardwareSMT::NUM_GLOBAL_STACKS];
 	
@@ -92,174 +88,162 @@
   tArray<int> inst_ft_cost;
 #endif
 
-  cHardwareSMT(const cHardwareSMT &); // disabled...  can't (easily) copy m_mem_lbls @dmb
+  
+  cHardwareSMT(const cHardwareSMT &); // @DMB - disabled...  can't (easily) copy m_mem_lbls
 
+  bool SingleProcess_PayCosts(const cInstruction & cur_inst);
+  bool SingleProcess_ExecuteInst(const cInstruction & cur_inst);
+  	
+
+  // --------  Stack Manipulation...  --------
+  inline cCPUStack& Stack(int stack_id); 
+  inline const cCPUStack& Stack(int stack_id) const;
+  inline cCPUStack& Stack(int stack_id, int in_thread);
+  inline const cCPUStack& Stack(int stack_id, int in_thread) const;
+
+  
+  // --------  Head Manipulation (including IP)  --------
+  const bool& AdvanceIP() const { return m_threads[m_cur_thread].advance_ip; }
+  bool& AdvanceIP() { return m_threads[m_cur_thread].advance_ip; }
+  
+  
+  // --------  Label Manipulation  -------
+  void ReadLabel(int max_size=nHardware::MAX_LABEL_SIZE);
+  cHeadMultiMem FindLabel(int direction);
+  int FindLabel_Forward(const cCodeLabel& search_label, const cGenome& search_genome, int pos);
+  int FindLabel_Backward(const cCodeLabel& search_label, const cGenome& search_genome, int pos);
+  cHeadMultiMem FindLabel(const cCodeLabel& in_label, int direction);
+  cHeadMultiMem FindFullLabel(const cCodeLabel& in_label);
+  const cCodeLabel& GetReadLabel() const { return m_threads[m_cur_thread].read_label; }
+  cCodeLabel& GetReadLabel() { return m_threads[m_cur_thread].read_label; }
+
+  
+  bool TriggerMutations_ScopeGenome(const cMutation * cur_mut,
+																		cCPUMemory & target_memory, cHeadCPU& cur_head, const double rate);
+  bool TriggerMutations_ScopeLocal(const cMutation * cur_mut,
+																	 cCPUMemory & target_memory, cHeadCPU& cur_head, const double rate);
+  int TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
+																	 cCPUMemory & target_memory, cHeadCPU& cur_head, const double rate);
+  void TriggerMutations_Body(int type, cCPUMemory & target_memory,
+														 cHeadCPU& cur_head);
+	
+  // ---------- Instruction Helpers -----------
+  int FindModifiedStack(int default_stack);
+  int FindModifiedNextStack(int default_stack);
+  int FindModifiedPreviousStack(int default_stack);
+  int FindModifiedComplementStack(int default_stack);
+  int FindModifiedHead(int default_head);
+  int FindNextStack(int default_stack);
+  int FindPreviousStack(int default_stack);
+  int FindComplementStack(int base_stack);
+  int FindMemorySpaceLabel(int mem_space);
+	
+  void Fault(int fault_loc, int fault_type, cString fault_desc=""); 
+  bool Allocate_Necro(const int new_size);
+  bool Allocate_Random(const int old_size, const int new_size);
+  bool Allocate_Default(const int new_size);
+  bool Allocate_Main(const int allocated_size);
+	
+  bool Divide_Main(const int mem_space_used, double mut_multiplier=1);
+  bool Divide_CheckViable(const int parent_size, const int child_size, const int mem_space);
+  void Divide_DoMutations(double mut_multiplier=1);
+  void Inject_DoMutations(double mut_multiplier, cCPUMemory & injected_code);
+  void Divide_TestFitnessMeasures();
+  void Mutate(const int mut_point);
+
+  bool InjectParasite(double mut_multiplier);
+
+  bool HeadCopy_ErrorCorrect(double reduction);
+  
+  void ReadInst(const int in_inst);
+	
+  inline int NormalizeMemSpace(int mem_space) const;
+
+  
 public:
   cHardwareSMT(cWorld* world, cOrganism* in_organism, cInstSet* in_inst_set);
   ~cHardwareSMT() { ; }
-  static cInstLibBase* GetInstLib();
+  static cInstLibBase* GetInstLib() { return s_inst_slib; }
   static cString GetDefaultInstFilename() { return "inst_lib.4stack"; }
-  static void WriteDefaultInstSet() { ; }
 	
   void Reset();
   void SingleProcess();
-  bool SingleProcess_PayCosts(const cInstruction & cur_inst);
-  bool SingleProcess_ExecuteInst(const cInstruction & cur_inst);
   void ProcessBonusInst(const cInstruction & inst);
-  void LoadGenome(const cGenome& new_genome) { m_mem_array[0] = new_genome; }
 	
   // --------  Helper methods  --------
+  int GetType() const { return HARDWARE_TYPE_CPU_SMT; }
   bool OK();
   void PrintStatus(std::ostream& fp);
 	
 	
   // --------  Stack Manipulation...  --------
   inline int GetStack(int depth=0, int stack_id=-1, int in_thread=-1) const;
-  cString GetActiveStackID(int stackID) const;
-  
-  // retrieves appropriate stack
-  inline cCPUStack & Stack(int stack_id); 
-  inline const cCPUStack & Stack(int stack_id) const;
-  inline cCPUStack & Stack(int stack_id, int in_thread);
-  inline const cCPUStack & Stack(int stack_id, int in_thread) const;
 	
+
   // --------  Head Manipulation (including IP)  --------
-  inline void SetActiveHead(const int new_head)
-  { m_threads[m_cur_thread].cur_head = (UCHAR) new_head; }
+  const cHeadMultiMem& GetHead(int head_id) const { return m_threads[m_cur_thread].heads[head_id]; }
+  cHeadMultiMem& GetHead(int head_id) { return m_threads[m_cur_thread].heads[head_id];}
+  const cHeadMultiMem& GetHead(int head_id, int thread) const { return m_threads[thread].heads[head_id]; }
+  cHeadMultiMem& GetHead(int head_id, int thread) { return m_threads[thread].heads[head_id];}
 	
-  int GetCurHead() const { return m_threads[m_cur_thread].cur_head; }
+  const cHeadMultiMem& IP() const { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
+  cHeadMultiMem& IP() { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
+  const cHeadMultiMem& IP(int thread) const { return m_threads[thread].heads[nHardware::HEAD_IP]; }
+  cHeadMultiMem& IP(int thread) { return m_threads[thread].heads[nHardware::HEAD_IP]; }
+	  
   
-  const cHeadMultiMem & GetHead(int head_id) const
-  { return m_threads[m_cur_thread].heads[head_id]; }
-  cHeadMultiMem & GetHead(int head_id) 
-  { return m_threads[m_cur_thread].heads[head_id];}
-  
-  const cHeadMultiMem & GetHead(int head_id, int thread) const
-  { return m_threads[thread].heads[head_id]; }
-  cHeadMultiMem & GetHead(int head_id, int thread) 
-  { return m_threads[thread].heads[head_id];}
-	
-  const cHeadMultiMem & GetActiveHead() const { return GetHead(GetCurHead()); }
-  cHeadMultiMem & GetActiveHead() { return GetHead(GetCurHead()); }
-	
-  void AdjustHeads();
-	
-  const cHeadMultiMem & IP() const { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
-  cHeadMultiMem & IP() { return m_threads[m_cur_thread].heads[nHardware::HEAD_IP]; }
-	
-  const cHeadMultiMem & IP(int thread) const { return m_threads[thread].heads[nHardware::HEAD_IP]; }
-  cHeadMultiMem & IP(int thread) { return m_threads[thread].heads[nHardware::HEAD_IP]; }
-	
-	
-  const bool & AdvanceIP() const { return m_threads[m_cur_thread].advance_ip; }
-  bool & AdvanceIP() { return m_threads[m_cur_thread].advance_ip; }
-	
   // --------  Label Manipulation  -------
-  void ReadLabel(int max_size=nHardware::MAX_LABEL_SIZE);
-  const cCodeLabel & GetLabel() const { return m_threads[m_cur_thread].next_label; }
-  cCodeLabel & GetLabel() { return m_threads[m_cur_thread].next_label; }
-  const cCodeLabel & GetReadLabel() const { return m_threads[m_cur_thread].read_label; }
-  cCodeLabel & GetReadLabel() { return m_threads[m_cur_thread].read_label; }
+  const cCodeLabel& GetLabel() const { return m_threads[m_cur_thread].next_label; }
+  cCodeLabel& GetLabel() { return m_threads[m_cur_thread].next_label; }
 	
-  // --------  Memory Manipulation  --------}
+  
+  // --------  Memory Manipulation  --------
   cCPUMemory& GetMemory() { return m_mem_array[0]; }
   const cCPUMemory& GetMemory() const { return m_mem_array[0]; }
-  cCPUMemory& GetMemory(int mem_space)
-  {
-    if(mem_space >= m_mem_array.GetSize())
-      mem_space %= m_mem_array.GetSize();
-    return m_mem_array[mem_space];
-  }
-  const cCPUMemory& GetMemory(int mem_space) const
-  {
-    if(mem_space >= m_mem_array.GetSize())
-      mem_space %= m_mem_array.GetSize();
-    return m_mem_array[mem_space];
-  }
+  cCPUMemory& GetMemory(int mem_space) { return m_mem_array[NormalizeMemSpace(mem_space)]; }
+  const cCPUMemory& GetMemory(int mem_space) const { return m_mem_array[NormalizeMemSpace(mem_space)]; }
   
+  
+  // --------  Register Manipulation  --------
+  const int GetRegister(int reg_id) const { return Stack(reg_id).Peek(); }
+  int& GetRegister(int reg_id) { return Stack(reg_id).Peek(); }
+  
+  
   // --------  Thread Manipulation  --------
   bool ForkThread(); // Adds a new thread based off of m_cur_thread.
   bool KillThread(); // Kill the current thread!
   inline void PrevThread(); // Shift the current thread in use.
   inline void NextThread();
   inline void SetThread(int value);
-  inline cInjectGenotype * GetCurThreadOwner(); 
-  inline cInjectGenotype * GetThreadOwner(int in_thread);
-  inline void SetThreadOwner(cInjectGenotype * in_genotype);
+  cInjectGenotype* GetCurThreadOwner() { return m_threads[m_cur_thread].owner; }
+  cInjectGenotype* GetThreadOwner(int in_thread) { return m_threads[in_thread].owner; }
+  void SetThreadOwner(cInjectGenotype* in_genotype) { m_threads[m_cur_thread].owner = in_genotype; }
 	
-  // --------  Tests  --------
-	
+  
+  // --------  Parasite Stuff  --------
   int TestParasite() const;
+  bool InjectHost(const cCodeLabel& in_label, const cGenome & injection);
+  int InjectThread(const cCodeLabel&, const cGenome&) { return -1; }
 	
+  
   // --------  Accessors  --------
   int GetNumThreads() const     { return m_threads.GetSize(); }
   int GetCurThread() const      { return m_cur_thread; }
   int GetCurThreadID() const    { return m_threads[m_cur_thread].GetID(); }
-	
   int GetThreadDist() const {
     if (GetNumThreads() == 1) return 0;
     return m_threads[0].heads[nHardware::HEAD_IP].GetPosition() - m_threads[1].heads[nHardware::HEAD_IP].GetPosition();
   }
 	
-  // Complex label manipulation...
-  cHeadMultiMem FindLabel(int direction);
-  int FindLabel_Forward(const cCodeLabel & search_label,
-												const cGenome & search_genome, int pos);
-  int FindLabel_Backward(const cCodeLabel & search_label,
-												 const cGenome & search_genome, int pos);
-  cHeadMultiMem FindLabel(const cCodeLabel & in_label, int direction);
-  cHeadMultiMem FindFullLabel(const cCodeLabel & in_label);
-	
-  int GetType() const { return HARDWARE_TYPE_CPU_SMT; }
-  bool InjectParasite(double mut_multiplier);
-  bool InjectHost(const cCodeLabel & in_label, const cGenome & injection);
-  int InjectThread(const cCodeLabel &, const cGenome &) { return -1; }
-  void Mutate(const int mut_point);
-  int PointMutate(const double mut_rate);
-  int FindFirstEmpty();
-  bool isEmpty(int mem_space_used);
-	
+  
+  // --------  Mutation  --------
+  int PointMutate(const double mut_rate);  
   bool TriggerMutations(int trigger);
-  bool TriggerMutations(int trigger, cHeadMultiMem & cur_head);
-  bool TriggerMutations_ScopeGenome(const cMutation * cur_mut,
-																		cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate);
-  bool TriggerMutations_ScopeLocal(const cMutation * cur_mut,
-																	 cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate);
-  int TriggerMutations_ScopeGlobal(const cMutation * cur_mut,
-																	 cCPUMemory & target_memory, cHeadMultiMem & cur_head, const double rate);
-  void TriggerMutations_Body(int type, cCPUMemory & target_memory,
-														 cHeadMultiMem & cur_head);
-	
-  void ReadInst(const int in_inst);
-	
+  bool TriggerMutations(int trigger, cHeadCPU& cur_head);
+
+
 private:
-  /////////---------- Instruction Helpers ------------//////////
-  int FindModifiedStack(int default_stack);
-  int FindModifiedNextStack(int default_stack);
-  int FindModifiedPreviousStack(int default_stack);
-  int FindModifiedComplementStack(int default_stack);
-  int FindModifiedHead(int default_head);
-  int FindNextStack(int default_stack);
-  int FindPreviousStack(int default_stack);
-  int FindComplementStack(int base_stack);
-  int FindMemorySpaceLabel(int mem_space);
-	
-  void Fault(int fault_loc, int fault_type, cString fault_desc=""); 
-  bool Allocate_Necro(const int new_size);
-  bool Allocate_Random(const int old_size, const int new_size);
-  bool Allocate_Default(const int new_size);
-  bool Allocate_Main(const int allocated_size);
-	
-  bool Divide_Main(const int mem_space_used, double mut_multiplier=1);
-  bool Divide_CheckViable(const int parent_size, const int child_size, const int mem_space);
-  void Divide_DoMutations(double mut_multiplier=1);
-  void Inject_DoMutations(double mut_multiplier, cCPUMemory & injected_code);
-  void Divide_TestFitnessMeasures();
-	
-  bool HeadCopy_ErrorCorrect(double reduction);
-	
-public:
-  /////////---------- Instruction Library ------------//////////
+  // ---------- Instruction Library -----------
   bool Inst_ShiftR();
   bool Inst_ShiftL();
   bool Inst_Val_Nand();
@@ -297,10 +281,6 @@
 };
 
 
-//////////////////
-//  cHardwareSMT
-//////////////////
-
 inline void cHardwareSMT::NextThread()
 {
   m_cur_thread++;
@@ -318,21 +298,6 @@
   if (value>=0 && value < GetNumThreads()) m_cur_thread = value;
 }
 
-inline cInjectGenotype * cHardwareSMT::GetCurThreadOwner() 
-{ 
-  return m_threads[m_cur_thread].owner; 
-}
-
-inline cInjectGenotype * cHardwareSMT::GetThreadOwner(int thread) 
-{ 
-  return m_threads[thread].owner; 
-}
-
-inline void cHardwareSMT::SetThreadOwner(cInjectGenotype * in_genotype)
-{ 
-  m_threads[m_cur_thread].owner = in_genotype; 
-}
-
 inline int cHardwareSMT::GetStack(int depth, int stack_id, int in_thread) const
 {
   if(stack_id<0 || stack_id > nHardwareSMT::NUM_STACKS) stack_id=0;
@@ -383,4 +348,11 @@
     return m_global_stacks[stack_id % nHardwareSMT::NUM_LOCAL_STACKS];
 }
 
+inline int cHardwareSMT::NormalizeMemSpace(int mem_space) const
+{
+  if(mem_space >= m_mem_array.GetSize())
+    mem_space %= m_mem_array.GetSize();
+  return mem_space;
+}
+
 #endif

Modified: development/source/cpu/cHeadMultiMem.h
===================================================================
--- development/source/cpu/cHeadMultiMem.h	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/cHeadMultiMem.h	2005-11-17 21:14:48 UTC (rev 402)
@@ -26,20 +26,19 @@
   int mem_space;
 
 public:
-
   cHeadMultiMem();
-  cHeadMultiMem(cHardwareBase * in_hardware, int in_pos = 0, int mem_space = 0);
-  cHeadMultiMem(const cHeadMultiMem & in_cpu_head);
+  cHeadMultiMem(cHardwareBase* in_hardware, int in_pos = 0, int mem_space = 0);
+  cHeadMultiMem(const cHeadMultiMem& in_cpu_head);
 
   void Adjust();
-  void Reset(int in_mem_space=0, cHardwareBase * new_hardware = NULL);
+  void Reset(int in_mem_space = 0, cHardwareBase* new_hardware = NULL);
   void Set(int new_pos, int in_mem_space = 0, cHardwareBase * in_hardware = NULL);
-  void Set(const cHeadMultiMem & in_head);
+  void Set(const cHeadMultiMem& in_head);
   void LoopJump(int jump);
-  const cCPUMemory & GetMemory() const;
-  cCPUMemory & GetMemory();
-  const cInstruction & GetInst() const;
-  const cInstruction & GetInst(int offset) const;
+  const cCPUMemory& GetMemory() const;
+  cCPUMemory& GetMemory();
+  const cInstruction& GetInst() const;
+  const cInstruction& GetInst(int offset) const;
 
   int GetMemSpace() const { return mem_space; }
 
@@ -48,15 +47,15 @@
   void RemoveInst();
   const cInstruction& GetNextInst();
 
-  bool & FlagCopied();
-  bool & FlagMutated();
-  bool & FlagExecuted();
-  bool & FlagBreakpoint();
-  bool & FlagPointMut();
-  bool & FlagCopyMut();
+  bool& FlagCopied();
+  bool& FlagMutated();
+  bool& FlagExecuted();
+  bool& FlagBreakpoint();
+  bool& FlagPointMut();
+  bool& FlagCopyMut();
 
   // Operator Overloading...
-  cHeadMultiMem & operator=(const cHeadMultiMem & in_cpu_head);
+  cHeadMultiMem& operator=(const cHeadMultiMem & in_cpu_head);
   bool operator==(const cHeadMultiMem & in_cpu_head) const; 
   bool AtEnd() const;
   bool InMemory() const;

Modified: development/source/cpu/sCPUStats.h
===================================================================
--- development/source/cpu/sCPUStats.h	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/sCPUStats.h	2005-11-17 21:14:48 UTC (rev 402)
@@ -5,8 +5,8 @@
 // before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
 //////////////////////////////////////////////////////////////////////////////
 
-#ifndef CPU_STATS_HH
-#define CPU_STATS_HH
+#ifndef sCPUStats_h
+#define sCPUStats_h
 
 /**
  * Class to facilitate passing information from CPU to Stats.
@@ -49,16 +49,11 @@
     }
   };
 
-
   // Contiually Set
   sMutationStats mut_stats;
 
+  void Setup() { mut_stats.Clear(); }
 
-  void Setup(int num_instructions) {
-    (void) num_instructions;
-    mut_stats.Clear();
-  }
-
   void Clear() {  // Called on any New Creature
     mut_stats.Clear();
   }

Modified: development/source/cpu/tInstLib.h
===================================================================
--- development/source/cpu/tInstLib.h	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/cpu/tInstLib.h	2005-11-17 21:14:48 UTC (rev 402)
@@ -75,4 +75,4 @@
   const cInstruction & GetInstError(){ return inst_error; }
 };
 
-#endif
\ No newline at end of file
+#endif

Modified: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/event/cEventManager.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -4094,4 +4094,4 @@
     cout << events[i]->GetDescription() << endl;
     delete events[i];
   }
-}
\ No newline at end of file
+}

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/main/cOrganism.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -55,7 +55,7 @@
 {
   // Initialization of structures...
   hardware = pop_interface.NewHardware(this);
-  cpu_stats.Setup(hardware->GetNumInst());
+  cpu_stats.Setup();
   pop_interface.SetCellID(-1);  // No cell at the moment...
 
   if (m_world->GetConfig().DEATH_METHOD.Get() > 0) {

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/main/cPopulation.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -9,6 +9,7 @@
 
 #include "cChangeList.h"
 #include "cClassificationManager.h"
+#include "cCodeLabel.h"
 #include "cConstSchedule.h"
 #include "cDataFile.h"
 #include "cEnvironment.h"
@@ -17,7 +18,6 @@
 #include "cGenotype.h"
 #include "cHardwareBase.h"
 #include "cHardwareManager.h"
-#include "cHardware4Stack.h"
 #include "cInitFile.h"
 #include "cInjectGenotype.h"
 #include "cInstUtil.h"
@@ -389,7 +389,7 @@
   if(injected_code.GetSize() ==0)
     return false;
   
-  cHardware4Stack & parent_cpu = (cHardware4Stack &) parent.GetHardware();
+  cHardwareBase& parent_cpu = parent.GetHardware();
   cInjectGenotype * parent_genotype = parent_cpu.GetCurThreadOwner();
   
   const int parent_id = parent.PopInterface().GetCellID();
@@ -403,7 +403,7 @@
   if(target_organism==NULL)
     return false;
   
-  cHardware4Stack & child_cpu = (cHardware4Stack &) target_organism->GetHardware();
+  cHardwareBase& child_cpu = target_organism->GetHardware();
   
   if(child_cpu.GetNumThreads() == m_world->GetConfig().MAX_CPU_THREADS.Get())
     return false;
@@ -432,7 +432,7 @@
 bool cPopulation::ActivateInject(const int cell_id, const cGenome & injected_code)
 {
   cInjectGenotype * child_genotype = m_world->GetClassificationManager().GetInjectGenotype(injected_code);
-  cHardware4Stack & child_cpu = (cHardware4Stack &) cell_array[cell_id].GetOrganism()->GetHardware();
+  cHardwareBase& child_cpu = cell_array[cell_id].GetOrganism()->GetHardware();
   if(cell_array[cell_id].GetOrganism()->InjectHost(cCodeLabel(), injected_code))
   {
     cell_array[cell_id].GetOrganism()->AddParasite(child_genotype);
@@ -1151,7 +1151,6 @@
     stats.SetGenoMapElement(i, organism->GetGenotype()->GetID());
     
 #ifdef INSTRUCTION_COUNT
-    //    for (int j=0; j < environment.GetInstSet().GetSize(); j++) {
     for (int j=0; j < m_world->GetNumInstructions(); j++) {
       stats.SumExeInst()[j].Add(organism->GetPhenotype().GetLastInstCount()[j]);
     }
@@ -1960,7 +1959,7 @@
       total+=cell_array[x].GetOrganism()->GetNumParasites();
       if(cell_array[x].GetOrganism()->GetNumParasites())
 	    {
-	      cHardware4Stack & cpu = (cHardware4Stack &) cell_array[x].GetOrganism()->GetHardware();
+	      cHardwareBase& cpu = cell_array[x].GetOrganism()->GetHardware();
 	      outfile << x << " ";
 	      outfile << cell_array[x].GetOrganism()->GetGenotype()->GetID() << " ";
 	      temp = cpu.GetThreadOwner(1);

Modified: development/source/main/cReactionProcess.cc
===================================================================
--- development/source/main/cReactionProcess.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/main/cReactionProcess.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -29,14 +29,10 @@
   , max_fraction(1.0)
   , product(NULL)
   , conversion(1.0)
-  , inst_id(-1)
   , lethal(0)
+  , inst_id(-1)
   , detect(NULL)
   , detection_threshold(0.0)
   , detection_error(0.0)
 {
 }
-
-cReactionProcess::~cReactionProcess()
-{
-}

Modified: development/source/main/cReactionProcess.h
===================================================================
--- development/source/main/cReactionProcess.h	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/main/cReactionProcess.h	2005-11-17 21:14:48 UTC (rev 402)
@@ -32,7 +32,7 @@
   double detection_error; // Var of Detection Event (as % of resource present)
 public:
   cReactionProcess();
-  ~cReactionProcess();
+  ~cReactionProcess() { ; }
 
   cResource * GetResource() const { return resource; }
   double GetValue() const { return value; }

Modified: development/source/main/cTaskLib.cc
===================================================================
--- development/source/main/cTaskLib.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/main/cTaskLib.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -1698,4 +1698,4 @@
   }
 
   return 0.0;
-}
\ No newline at end of file
+}

Modified: development/source/tools/cChangeList.cc
===================================================================
--- development/source/tools/cChangeList.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/tools/cChangeList.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -17,9 +17,9 @@
 }
 
 cChangeList::cChangeList(int capacity)
-: m_change_list(0)
+: m_change_count(0)
+, m_change_list(0)
 , m_change_tracking(0)
-, m_change_count(0)
 { ResizeClear(capacity); }
 
 int cChangeList::GetSize() const { return m_change_list.GetSize(); }

Modified: development/source/viewer/cSymbolUtil.cc
===================================================================
--- development/source/viewer/cSymbolUtil.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/viewer/cSymbolUtil.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -14,9 +14,6 @@
 #include "cPopulationCell.h"
 #include "cSpecies.h"
 #include "cHardwareBase.h"
-#include "cHardware4Stack.h"
-#include "cHardwareCPU.h"
-#include "cHardwareSMT.h"
 
 using namespace std;
 
@@ -107,21 +104,7 @@
 char cSymbolUtil::GetThreadSymbol(const cPopulationCell & cell)
 {
   if (cell.IsOccupied() == false) return ' ';
-  const int hw_type = static_cast<cHardwareBase*>(&cell.GetOrganism()->GetHardware())->GetType();
-  int num_threads;
-  switch (hw_type)
-  {
-    case HARDWARE_TYPE_CPU_ORIGINAL:
-      num_threads = ((cHardwareCPU &) cell.GetOrganism()->GetHardware()).GetNumThreads();
-      return (char) ('0' + num_threads);
-    case HARDWARE_TYPE_CPU_4STACK:
-      num_threads = ((cHardware4Stack &) cell.GetOrganism()->GetHardware()).GetNumThreads();
-      return (char) ('0' + num_threads);
-    case HARDWARE_TYPE_CPU_SMT:
-      num_threads = static_cast<cHardwareSMT&>(cell.GetOrganism()->GetHardware()).GetNumThreads();
-      return (char) ('0' + num_threads);
-  }
-  return '0';
+  return '0' + cell.GetOrganism()->GetHardware().GetNumThreads();
 }
 
 char cSymbolUtil::GetLineageSymbol(const cPopulationCell & cell)

Modified: development/source/viewer/cView.cc
===================================================================
--- development/source/viewer/cView.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/viewer/cView.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -116,14 +116,6 @@
 
 void cView::NotifyUpdate()
 {
-  // If we're locked onto a specific thread, only stop for it.
-  /*if (info.GetPauseLevel() == PAUSE_ADVANCE_STEP &&
-      info.GetThreadLock() != -1  &&
-      info.GetThreadLock() != info.GetActiveCell()->GetOrganism()->GetHardware().ViewerLock()){
-    return;
-    }*/
-
-
   bar_screen->Update();
   info.UpdateSymbols();
 

Modified: development/source/viewer/cZoomScreen.cc
===================================================================
--- development/source/viewer/cZoomScreen.cc	2005-11-16 00:50:47 UTC (rev 401)
+++ development/source/viewer/cZoomScreen.cc	2005-11-17 21:14:48 UTC (rev 402)
@@ -679,9 +679,9 @@
   Print(10, 43, "%2d/%2d", hardwareCPU.GetCurThread() + 1,
         hardwareCPU.GetNumThreads());
   
-  Print(12, 34, "%14d", hardwareCPU.Register(0));
-  Print(13, 34, "%14d", hardwareCPU.Register(1));
-  Print(14, 34, "%14d", hardwareCPU.Register(2));
+  Print(12, 34, "%14d", hardwareCPU.GetRegister(0));
+  Print(13, 34, "%14d", hardwareCPU.GetRegister(1));
+  Print(14, 34, "%14d", hardwareCPU.GetRegister(2));
   Print(15, 34, "%14d", hardwareCPU.GetStack(0));
   
   cHeadCPU inst_ptr(hardwareCPU.IP());
@@ -739,11 +739,6 @@
     inst_ptr.Advance();
   }
   
-  // Flags...
-  //if (hardwareCPU.GetMalActive()) SetBoldColor(COLOR_CYAN);
-  //else SetColor(COLOR_CYAN);
-  //Print(CPU_FLAGS_Y + 1, CPU_FLAGS_X + 1, "Mem Allocated");
-  
   // And print the IP.
   const cHeadMultiMem & active_inst_ptr = hardware4Stack.IP();
   // @CAO assume no parasites for now.
@@ -780,11 +775,6 @@
     inst_ptr.Advance();
   }
   
-  // Flags...
-  //if (hardwareCPU.GetMalActive()) SetBoldColor(COLOR_CYAN);
-  //else SetColor(COLOR_CYAN);
-  //Print(CPU_FLAGS_Y + 1, CPU_FLAGS_X + 1, "Mem Allocated");
-  
   // And print the IP.
   const cHeadMultiMem & active_inst_ptr = hardware4Stack.IP();
   // @CAO assume no parasites for now.
@@ -862,7 +852,7 @@
   // Place the registers onto the screen.
   SetBoldColor(COLOR_CYAN);
   for (int i = 0; i < nHardwareCPU::NUM_REGISTERS; i++) {
-    Print(REG_Y+3 + i, REG_X+6, "%11d", hardwareCPU.Register(i));
+    Print(REG_Y+3 + i, REG_X+6, "%11d", hardwareCPU.GetRegister(i));
   }
   
   // Place the active stack onto the screen.
@@ -870,8 +860,7 @@
   // Stack A
   // SetBoldColor(COLOR_CYAN);   // -Redundant
   SetColor(COLOR_WHITE);
-  char stack_letter = 'A' + hardwareCPU.GetActiveStackID();
-  Print(STACK_Y + 1, STACK_X + 2, "Stack %c", stack_letter);
+  Print(STACK_Y + 1, STACK_X + 2, "Stack %s", 'A' + hardwareCPU.GetActiveStack());
   
   SetBoldColor(COLOR_CYAN);
   Print(STACK_Y+3, STACK_X + 2, "%11d", hardwareCPU.GetStack(0));
@@ -1016,7 +1005,7 @@
   SetColor(COLOR_WHITE);
   
   Print(STACK_Y, STACK_X + 2, "Stack   :");
-  Print(STACK_Y, STACK_X + 8, "%s" , hardware4Stack.GetActiveStackID(cur_stack)());
+  Print(STACK_Y, STACK_X + 8, "%cX" , 'A' + cur_stack);
   
   //SetBoldColor(COLOR_CYAN);
   //Print(STACK_Y+2, STACK_X + 2, "%11d", hardware4Stack.GetStack(0, cur_stack));
@@ -1159,7 +1148,7 @@
   SetColor(COLOR_WHITE);
   
   Print(STACK_Y, STACK_X + 2, "Stack   :");
-  Print(STACK_Y, STACK_X + 8, "%s" , hardware4Stack.GetActiveStackID(cur_stack)());
+  Print(STACK_Y, STACK_X + 8, "%cX" , 'A' + cur_stack);
   
   //SetBoldColor(COLOR_CYAN);
   //Print(STACK_Y+2, STACK_X + 2, "%11d", hardware4Stack.GetStack(0, cur_stack));
@@ -1418,9 +1407,7 @@
 void cZoomScreen::ViewMemory()
 {
   // Collect all of the needed variables.
-  cHardwareCPU & hardware =
-  (cHardwareCPU &) info.GetActiveCell()->GetOrganism()->GetHardware();
-  //  cosnt cInstSet & inst_set = hardware.GetInstSet();
+  cHardwareCPU& hardware = (cHardwareCPU&) info.GetActiveCell()->GetOrganism()->GetHardware();
   cHeadCPU view_head( hardware.IP() );
   if (parasite_zoom == true) {
     view_head.Set(0, &(info.GetActiveCell()->GetOrganism()->GetHardware()) );
@@ -1558,7 +1545,7 @@
   
   for (int i = 0; i < 3; i++) {
     const char reg_letter = 'A' + i;
-    const int reg_value = hardware.Register(i);
+    const int reg_value = hardware.GetRegister(i);
     window->SetBoldColor(COLOR_WHITE);
     window->Print(4+i, 2, "%cX:", reg_letter);
     window->Print(4+i, 17, '[');
@@ -1598,7 +1585,7 @@
     (cHardwareCPU &) info.GetActiveCell()->GetOrganism()->GetHardware();
   
   bool finished = false;
-  int active_stack = hardware.GetActiveStackID();
+  int active_stack = hardware.GetActiveStack();
   
   
   while (finished == false) {
@@ -1879,21 +1866,7 @@
   
   int num_threads = 0;
   if (info.GetActiveCell()->GetOrganism() != NULL) {
-    if(info.GetConfig().HARDWARE_TYPE.Get()==HARDWARE_TYPE_CPU_ORIGINAL)
-    {
-      cHardwareCPU& hw = static_cast<cHardwareCPU&>(info.GetActiveCell()->GetOrganism()->GetHardware());
-      num_threads = hw.GetNumThreads();
-    }
-    else if(info.GetConfig().HARDWARE_TYPE.Get()==HARDWARE_TYPE_CPU_4STACK)
-    {
-      cHardware4Stack& hw = static_cast<cHardware4Stack&>(info.GetActiveCell()->GetOrganism()->GetHardware());
-      num_threads = hw.GetNumThreads();
-    }
-    else if(info.GetConfig().HARDWARE_TYPE.Get()==HARDWARE_TYPE_CPU_SMT)
-    {
-      cHardwareSMT& hw = static_cast<cHardwareSMT&>(info.GetActiveCell()->GetOrganism()->GetHardware());
-      num_threads = hw.GetNumThreads();
-    }
+    num_threads = info.GetActiveCell()->GetOrganism()->GetHardware().GetNumThreads();
   }
   switch(in_char) {
     case 't':

Modified: development/status.xml
===================================================================
--- development/status.xml	2005-11-16 00:50:47 UTC (rev 401)
+++ development/status.xml	2005-11-17 21:14:48 UTC (rev 402)
@@ -920,9 +920,6 @@
         New cHardware base class, separate from Hardware CPU
       </action>
       <action context="refactor" dev="DMB">
-        [ lineage ]
-      </action>
-      <action context="refactor" dev="DMB">
         shift analyze commands into their own objects
       </action>
       <action context="refactor" dev="DMB">




More information about the Avida-cvs mailing list