DefaultCommit<Impl>::updateStatus()
 {
     // reset ROB changed variable
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
-    while (threads != (*activeThreads).end()) {
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
         unsigned tid = *threads++;
+
         changedROBNumEntries[tid] = false;
 
         // Also check if any of the threads has a trap pending
 {
     int squashes = 0;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (commitStatus[tid] == ROBSquashing) {
 bool
 DefaultCommit<Impl>::changedROBEntries()
 {
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (changedROBNumEntries[tid]) {
         return;
     }
 
-    if ((*activeThreads).size() <= 0)
+    if (activeThreads->empty())
         return;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
     // Check if any of the threads are done squashing.  Change the
     // status if they are done.
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (commitStatus[tid] == ROBSquashing) {
 
     markCompletedInsts();
 
-    threads = (*activeThreads).begin();
+    threads = activeThreads->begin();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (!rob->isEmpty(tid) && rob->readHeadInst(tid)->readyToCommit()) {
     ////////////////////////////////////
     // Check for any possible squashes, handle them first
     ////////////////////////////////////
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         // Not sure which one takes priority.  I think if we have
     }
 
     //Check for any activity
-    threads = (*activeThreads).begin();
+    threads = activeThreads->begin();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (changedROBNumEntries[tid]) {
 bool
 DefaultCommit<Impl>::robDoneSquashing()
 {
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (!rob->isDoneSquashing(tid))
             return -1;
         }
     } else {
-        int tid = (*activeThreads).front();
+        assert(!activeThreads->empty());
+        int tid = activeThreads->front();
 
         if (commitStatus[tid] == Running ||
             commitStatus[tid] == Idle ||
     unsigned oldest = 0;
     bool first = true;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (!rob->isEmpty(tid) &&
 
 bool
 DefaultDecode<Impl>::skidsEmpty()
 {
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
-        if (!skidBuffer[*threads++].empty())
+    while (threads != end) {
+        unsigned tid = *threads++;
+        if (!skidBuffer[tid].empty())
             return false;
     }
 
 {
     bool any_unblocking = false;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
-
-    threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (decodeStatus[tid] == Unblocking) {
 
     toRenameIndex = 0;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
     sortInsts();
 
     //Check stall and squash signals.
-    while (threads != (*activeThreads).end()) {
-    unsigned tid = *threads++;
+    while (threads != end) {
+        unsigned tid = *threads++;
 
         DPRINTF(Decode,"Processing [tid:%i]\n",tid);
         status_change =  checkSignalsAndUpdate(tid) || status_change;
 
 DefaultFetch<Impl>::updateFetchStatus()
 {
     //Check Running
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
-
-    while (threads != (*activeThreads).end()) {
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (fetchStatus[tid] == Running ||
 void
 DefaultFetch<Impl>::tick()
 {
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
     bool status_change = false;
 
     wroteToTimeBuffer = false;
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         // Check the signals for each thread to determine the proper status
             return -1;
         }
     } else {
-        int tid = *((*activeThreads).begin());
+        std::list<unsigned>::iterator thread = activeThreads->begin();
+        assert(thread != activeThreads->end());
+        int tid = *thread;
 
         if (fetchStatus[tid] == Running ||
             fetchStatus[tid] == IcacheAccessComplete ||
 {
     std::priority_queue<unsigned> PQ;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         PQ.push(fromIEW->iewInfo[tid].iqCount);
 {
     std::priority_queue<unsigned> PQ;
 
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
-
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         PQ.push(fromIEW->iewInfo[tid].ldstqCount);
 int
 DefaultFetch<Impl>::branchCount()
 {
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator thread = activeThreads->begin();
+    assert(thread != activeThreads->end());
+    unsigned tid = *thread;
+
     panic("Branch Count Fetch policy unimplemented\n");
-    return *threads;
+    return 0 * tid;
 }
 
 {
     int max=0;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
-        unsigned thread_count = skidBuffer[*threads++].size();
+    while (threads != end) {
+        unsigned tid = *threads++;
+        unsigned thread_count = skidBuffer[tid].size();
         if (max < thread_count)
             max = thread_count;
     }
 bool
 DefaultIEW<Impl>::skidsEmpty()
 {
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (threads != (*activeThreads).end()) {
-        if (!skidBuffer[*threads++].empty())
+        if (!skidBuffer[tid].empty())
             return false;
     }
 
 {
     bool any_unblocking = false;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    threads = (*activeThreads).begin();
-
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (dispatchStatus[tid] == Unblocking) {
     wbNumInst = 0;
     wbCycle = 0;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
         fetchRedirect[tid] = false;
     }
     // Free function units marked as being freed this cycle.
     fuPool->processFreeUnits();
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
     // Check stall and squash signals, dispatch any instructions.
-    while (threads != (*activeThreads).end()) {
-           unsigned tid = *threads++;
+    while (threads != end) {
+        unsigned tid = *threads++;
 
         DPRINTF(IEW,"Issue: Processing [tid:%i]\n",tid);
 
     // nonspeculative instruction.
     // This is pretty inefficient...
 
-    threads = (*activeThreads).begin();
-    while (threads != (*activeThreads).end()) {
+    threads = activeThreads->begin();
+    while (threads != end) {
         unsigned tid = (*threads++);
 
         DPRINTF(IEW,"Processing [tid:%i]\n",tid);
 
 InstructionQueue<Impl>::resetEntries()
 {
     if (iqPolicy != Dynamic || numThreads > 1) {
-        int active_threads = (*activeThreads).size();
+        int active_threads = activeThreads->size();
 
-        std::list<unsigned>::iterator threads  = (*activeThreads).begin();
-        std::list<unsigned>::iterator list_end = (*activeThreads).end();
+        std::list<unsigned>::iterator threads = activeThreads->begin();
+        std::list<unsigned>::iterator end = activeThreads->end();
+
+        while (threads != end) {
+            unsigned tid = *threads++;
 
-        while (threads != list_end) {
             if (iqPolicy == Partitioned) {
-                maxEntries[*threads++] = numEntries / active_threads;
+                maxEntries[tid] = numEntries / active_threads;
             } else if(iqPolicy == Threshold && active_threads == 1) {
-                maxEntries[*threads++] = numEntries;
+                maxEntries[tid] = numEntries;
             }
         }
     }
 
 LSQ<Impl>::resetEntries()
 {
     if (lsqPolicy != Dynamic || numThreads > 1) {
-        int active_threads = (*activeThreads).size();
-
-        std::list<unsigned>::iterator threads  = (*activeThreads).begin();
-        std::list<unsigned>::iterator list_end = (*activeThreads).end();
+        int active_threads = activeThreads->size();
 
         int maxEntries;
 
             maxEntries = LQEntries;
         }
 
-        while (threads != list_end) {
-            resizeEntries(maxEntries,*threads++);
+        std::list<unsigned>::iterator threads  = activeThreads->begin();
+        std::list<unsigned>::iterator end = activeThreads->end();
+
+        while (threads != end) {
+            unsigned tid = *threads++;
+
+            resizeEntries(maxEntries, tid);
         }
     }
 }
 void
 LSQ<Impl>::tick()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
+    while (threads != end) {
+        unsigned tid = *threads++;
 
         thread[tid].tick();
     }
 void
 LSQ<Impl>::writebackStores()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
+    while (threads != end) {
+        unsigned tid = *threads++;
 
         if (numStoresToWB(tid) > 0) {
             DPRINTF(Writeback,"[tid:%i] Writing back stores. %i stores "
 LSQ<Impl>::violation()
 {
     /* Answers: Does Anybody Have a Violation?*/
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (thread[tid].violation())
             return true;
     }
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += getCount(tid);
     }
 
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += numLoads(tid);
     }
 
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += thread[tid].numStores();
     }
 
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += thread[tid].numLoadsReady();
     }
 
 {
     unsigned total = 0;
 
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         total += thread[tid].numFreeEntries();
     }
 
 bool
 LSQ<Impl>::isFull()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
-        if (! (thread[tid].lqFull() || thread[tid].sqFull()) )
+    while (threads != end) {
+        unsigned tid = *threads++;
+
+        if (!(thread[tid].lqFull() || thread[tid].sqFull()))
             return false;
     }
 
 {
     //@todo: Change to Calculate All Entries for
     //Dynamic Policy
-    if( lsqPolicy == Dynamic )
+    if (lsqPolicy == Dynamic)
         return isFull();
     else
         return thread[tid].lqFull() || thread[tid].sqFull();
 bool
 LSQ<Impl>::lqFull()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (!thread[tid].lqFull())
             return false;
     }
 bool
 LSQ<Impl>::sqFull()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (!sqFull(tid))
             return false;
     }
 bool
 LSQ<Impl>::isStalled()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (!thread[tid].isStalled())
             return false;
     }
 bool
 LSQ<Impl>::hasStoresToWB()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    if ((*activeThreads).empty())
+    if (threads == end)
         return false;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
+    while (threads != end) {
+        unsigned tid = *threads++;
+
         if (!hasStoresToWB(tid))
             return false;
     }
 bool
 LSQ<Impl>::willWB()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         if (!willWB(tid))
             return false;
     }
 void
 LSQ<Impl>::dumpInsts()
 {
-    std::list<unsigned>::iterator active_threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
+
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-    while (active_threads != (*activeThreads).end()) {
-        unsigned tid = *active_threads++;
         thread[tid].dumpInsts();
     }
 }
 
 
     sortInsts();
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
     // Check stall and squash signals.
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         DPRINTF(Rename, "Processing [tid:%i]\n", tid);
         cpu->activityThisCycle();
     }
 
-    threads = (*activeThreads).begin();
+    threads = activeThreads->begin();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         // If we committed this cycle then doneSeqNum will be > 0
 bool
 DefaultRename<Impl>::skidsEmpty()
 {
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
-        if (!skidBuffer[*threads++].empty())
+    while (threads != end) {
+        unsigned tid = *threads++;
+
+        if (!skidBuffer[tid].empty())
             return false;
     }
 
 {
     bool any_unblocking = false;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
-
-    threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (renameStatus[tid] == Unblocking) {
 
         // Subtract off the base offset for miscellaneous registers.
         arch_reg = arch_reg - numLogicalRegs;
 
+        DPRINTF(Rename, "Renamed misc reg %d\n", arch_reg);
+
         // No renaming happens to the misc. registers.  They are
         // simply the registers that come after all the physical
         // registers; thus take the base architected register and add
         assert(renamed_reg < numPhysicalRegs + numMiscRegs);
     }
 
+    DPRINTF(Rename, "Renamed reg %d to physical reg %d old mapping was %d\n",
+            arch_reg, renamed_reg, prev_reg);
+
     return RenameInfo(renamed_reg, prev_reg);
 }
 
 
 ROB<Impl>::resetEntries()
 {
     if (robPolicy != Dynamic || numThreads > 1) {
-        int active_threads = (*activeThreads).size();
+        int active_threads = activeThreads->size();
 
-        std::list<unsigned>::iterator threads  = (*activeThreads).begin();
-        std::list<unsigned>::iterator list_end = (*activeThreads).end();
+        std::list<unsigned>::iterator threads = activeThreads->begin();
+        std::list<unsigned>::iterator end = activeThreads->end();
+
+        while (threads != end) {
+            unsigned tid = *threads++;
 
-        while (threads != list_end) {
             if (robPolicy == Partitioned) {
-                maxEntries[*threads++] = numEntries / active_threads;
+                maxEntries[tid] = numEntries / active_threads;
             } else if (robPolicy == Threshold && active_threads == 1) {
-                maxEntries[*threads++] = numEntries;
+                maxEntries[tid] = numEntries;
             }
         }
     }
 ROB<Impl>::canCommit()
 {
     //@todo: set ActiveThreads through ROB or CPU
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (isHeadReady(tid)) {
     bool first_valid = true;
 
     // @todo: set ActiveThreads through ROB or CPU
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
-        unsigned thread_num = *threads++;
+    while (threads != end) {
+        unsigned tid = *threads++;
 
-        if (instList[thread_num].empty())
+        if (instList[tid].empty())
             continue;
 
         if (first_valid) {
-            head = instList[thread_num].begin();
+            head = instList[tid].begin();
             lowest_num = (*head)->seqNum;
             first_valid = false;
             continue;
         }
 
-        InstIt head_thread = instList[thread_num].begin();
+        InstIt head_thread = instList[tid].begin();
 
         DynInstPtr head_inst = (*head_thread);
 
     tail = instList[0].end();
     bool first_valid = true;
 
-    std::list<unsigned>::iterator threads = (*activeThreads).begin();
+    std::list<unsigned>::iterator threads = activeThreads->begin();
+    std::list<unsigned>::iterator end = activeThreads->end();
 
-    while (threads != (*activeThreads).end()) {
+    while (threads != end) {
         unsigned tid = *threads++;
 
         if (instList[tid].empty()) {
 
 InstQueue<Impl>::resetEntries()
 {
     if (iqPolicy != Dynamic || numThreads > 1) {
-        int active_threads = (*activeThreads).size();
+        int active_threads = activeThreads->size();
 
-        list<unsigned>::iterator threads  = (*activeThreads).begin();
-        list<unsigned>::iterator list_end = (*activeThreads).end();
+        std::list<unsigned>::iterator threads = activeThreads->begin();
+        std::list<unsigned>::iterator end = activeThreads->end();
+
+        while (threads != end) {
+            unsigned tid = *threads++;
 
-        while (threads != list_end) {
             if (iqPolicy == Partitioned) {
-                maxEntries[*threads++] = numEntries / active_threads;
-            } else if(iqPolicy == Threshold && active_threads == 1) {
-                maxEntries[*threads++] = numEntries;
+                maxEntries[tid] = numEntries / active_threads;
+            } else if (iqPolicy == Threshold && active_threads == 1) {
+                maxEntries[tid] = numEntries;
             }
         }
     }