diff --git a/SpectrumAWG/blacs_workers.py b/SpectrumAWG/blacs_workers.py
index 16bc26f59501494aa130781a1e54e0a6daf59a45..2b3fcf78a2071f402dca460027da02e43b23a5dc 100644
--- a/SpectrumAWG/blacs_workers.py
+++ b/SpectrumAWG/blacs_workers.py
@@ -69,10 +69,10 @@ class SpectrumAWGWorker(Worker):
                     self.smart_cache = {}
 
                 last_index = len(group[ch].attrs)-1
-                times = np.sort(np.array(group[ch].attrs).astype(np.float32)) # The attribute names are strings and sorted wrong. TODO: better perfomance without sorting here?
-                for index,t in enumerate(times):
+                for index in range(len(group[ch].attrs)):
+                    index_h5 = str(index) # The index in the h5 file is a str
                     ### LOOP TROUGH STREAMING STEPS ###
-                    instruction = group[ch].attrs[t]
+                    instruction = group[ch].attrs[index_h5]
                     instruction_hash = hash(instruction.tobytes())
                     if instruction_hash in self.smart_cache:
                         memory_index = self.smart_cache[instruction_hash]
@@ -95,8 +95,8 @@ class SpectrumAWGWorker(Worker):
                             initial_values[memory_index] = f"f:{freq}, a:{ampl}, p:{phase}"
                         else:
                             raise RuntimeError("Instruction length does not match, what happened??")
-                        if t in group[ch]["labels"].attrs:
-                            initial_values[memory_index] = group[ch]["labels"].attrs[t]
+                        if index_h5 in group[ch]["labels"].attrs:
+                            initial_values[memory_index] = group[ch]["labels"].attrs[index_h5]
                         self.AWG.transfer_sequence_replay_samples(memory_index,data)
                     if index!=last_index:
                         self.AWG.seq_set_sequence_step(index,memory_index,index+1,1,'on_trigger',last_step=False)
diff --git a/SpectrumAWG/labscript_devices.py b/SpectrumAWG/labscript_devices.py
index 41e83e0ea9b6eee0b3e572909850227f44167660..4ea4fdead161cda9657d3c422aaf6605cf0752e8 100644
--- a/SpectrumAWG/labscript_devices.py
+++ b/SpectrumAWG/labscript_devices.py
@@ -168,10 +168,10 @@ class SpectrumAWG(Device):
             group.require_group(output.connection)
             group[output.connection].require_group("labels")
 
-            for t in change_times:
-                group[output.connection].attrs[str(t)] = output.instructions[t][:-1]
+            for i,t in enumerate(np.sort(change_times)):
+                group[output.connection].attrs[str(i)] = output.instructions[t][:-1]
                 if output.instructions[t][-1] is not None:
-                    group[output.connection]["labels"].attrs[str(t)] = output.instructions[t][-1]
+                    group[output.connection]["labels"].attrs[str(i)] = output.instructions[t][-1]