diff --git a/hercules_ir/src/parse.rs b/hercules_ir/src/parse.rs
index 6c533befeea6487128ba05df18c2558eca358765..cdad54f935afd7b79eaf258b8ec0a83415ecb5ef 100644
--- a/hercules_ir/src/parse.rs
+++ b/hercules_ir/src/parse.rs
@@ -37,6 +37,7 @@ struct Context<'a> {
     interned_constants: HashMap<Constant, ConstantID>,
     interned_dynamic_constants: HashMap<DynamicConstant, DynamicConstantID>,
     reverse_dynamic_constant_map: HashMap<DynamicConstantID, DynamicConstant>,
+    interned_labels: HashMap<String, LabelID>,
 }
 
 /*
@@ -97,6 +98,16 @@ impl<'a> Context<'a> {
             id
         }
     }
+
+    fn get_label_id(&mut self, label: String) -> LabelID {
+        if let Some(id) = self.interned_labels.get(&label) {
+            *id
+        } else {
+            let id = LabelID::new(self.interned_labels.len());
+            self.interned_labels.insert(label, id);
+            id
+        }
+    }
 }
 
 /*
@@ -153,12 +164,16 @@ fn parse_module<'a>(ir_text: &'a str, context: Context<'a>) -> nom::IResult<&'a
     for (dynamic_constant, id) in context.interned_dynamic_constants {
         dynamic_constants[id.idx()] = dynamic_constant;
     }
+    let mut labels = vec!["".to_string(); context.interned_labels.len()];
+    for (label, id) in context.interned_labels {
+        labels[id.idx()] = label;
+    }
     let module = Module {
         functions: fixed_functions,
         types,
         constants,
         dynamic_constants,
-        labels: vec![],
+        labels,
     };
     Ok((rest, module))
 }
@@ -227,10 +242,13 @@ fn parse_function<'a>(
     // `nodes`, as returned by parsing, is in parse order, which may differ from
     // the order dictated by NodeIDs in the node name intern map.
     let mut fixed_nodes = vec![Node::Start; context.borrow().node_ids.len()];
+    let mut labels = vec![HashSet::new(); fixed_nodes.len()];
     for (name, node) in nodes {
         // We can remove items from the node name intern map now, as the map
         // will be cleared during the next iteration of parse_function.
-        fixed_nodes[context.borrow_mut().node_ids.remove(name).unwrap().idx()] = node;
+        let id = context.borrow_mut().node_ids.remove(name).unwrap();
+        fixed_nodes[id.idx()] = node;
+        labels[id.idx()].insert(context.borrow_mut().get_label_id(name.to_string()));
     }
 
     // The nodes removed from node_ids in the previous step are nodes that are
@@ -264,7 +282,7 @@ fn parse_function<'a>(
             entry: true,
             nodes: fixed_nodes,
             schedules: vec![vec![]; num_nodes],
-            labels: vec![HashSet::new(); num_nodes],
+            labels,
             device: None,
         },
     ))
@@ -1232,7 +1250,7 @@ mod tests {
 
     #[test]
     fn parse_ir1() {
-        parse(
+        let module = parse(
             "
 fn myfunc(x: i32) -> i32
   y = call<0>(add, x, x)
@@ -1246,5 +1264,14 @@ fn add<1>(x: i32, y: i32) -> i32
 ",
         )
         .unwrap();
+        assert_eq!(module.labels.len(), 5);
+        assert_eq!(
+            module.functions[0].labels.len(),
+            module.functions[0].nodes.len()
+        );
+        assert_eq!(
+            module.functions[1].labels.len(),
+            module.functions[1].nodes.len()
+        );
     }
 }
diff --git a/hercules_opt/src/editor.rs b/hercules_opt/src/editor.rs
index 6271a9580f80bfd76701c76db1f48ad3e0c496ad..60745f214d182393fcddac163006532426103199 100644
--- a/hercules_opt/src/editor.rs
+++ b/hercules_opt/src/editor.rs
@@ -532,7 +532,13 @@ impl<'a, 'b> FunctionEdit<'a, 'b> {
             if let Some(schedules) = self.added_and_updated_schedules.get_mut(&id) {
                 schedules.push(schedule);
             } else {
-                let mut schedules = self.editor.function.schedules[id.idx()].clone();
+                let mut schedules = self
+                    .editor
+                    .function
+                    .schedules
+                    .get(id.idx())
+                    .unwrap_or(&vec![])
+                    .clone();
                 if !schedules.contains(&schedule) {
                     schedules.push(schedule);
                 }
@@ -569,7 +575,13 @@ impl<'a, 'b> FunctionEdit<'a, 'b> {
             if let Some(labels) = self.added_and_updated_labels.get_mut(&id) {
                 labels.insert(label);
             } else {
-                let mut labels = self.editor.function.labels[id.idx()].clone();
+                let mut labels = self
+                    .editor
+                    .function
+                    .labels
+                    .get(id.idx())
+                    .unwrap_or(&HashSet::new())
+                    .clone();
                 labels.insert(label);
                 self.added_and_updated_labels.insert(id, labels);
             }
diff --git a/juno_scheduler/src/pm.rs b/juno_scheduler/src/pm.rs
index 72150570d9446a33be19b8586b8092801f18dffe..beaf73e3da5691239a9c36dde45a2d4f593e253f 100644
--- a/juno_scheduler/src/pm.rs
+++ b/juno_scheduler/src/pm.rs
@@ -1576,6 +1576,7 @@ fn run_pass(
             pm.bbs = bbs;
         }
     }
+    println!("Ran Pass: {:?}", pass);
 
     Ok((result, changed))
 }