diff --git a/src/oud2_parser.pl b/src/oud2_parser.pl
index 03bbd503a6be5bcf3197eb50f90a5da790a964f3..c0836808034d4e8f6172b794c6ffdb03c4566034 100644
--- a/src/oud2_parser.pl
+++ b/src/oud2_parser.pl
@@ -265,6 +265,7 @@ foreach my $frame (values %{ $master{'rosen'} })
 {
     my @old_ekis = @{ $frame->{'eki'} };
     my @new_ekis;
+    my %dict;
     my @new_refs;
     my $index = 0;
     my $update_index = 1;
@@ -279,7 +280,7 @@ foreach my $frame (values %{ $master{'rosen'} })
 
 	# Run all similarity checks first
 	# Station occurs twice on the same route (branch line)
-	foreach my $old (@new_ekis)
+	foreach my $old (values @new_ekis)
 	{
 	    if ($old->{'ekimei'} eq $ekimei)
 	    {
@@ -300,6 +301,7 @@ foreach my $frame (values %{ $master{'rosen'} })
 	
 	my $id = $frame->{'id'} . "_$index";
 	print "Adding station $ekimei to master frame with id $id\n";
+	$master{'eki_index'}{$id} = \%new_struct;
 
 	$new_struct{'ekimei'} = $ekimei;
 	$new_struct{'found_in'} = $frame->{'id'};
@@ -312,8 +314,4 @@ foreach my $frame (values %{ $master{'rosen'} })
     # Replace old station structures with references
     # The order is conserved so there's no need to modify {'jikoku'} in {'dia'}
     $frame->{'eki'} = \@new_ekis;
-    
-    push @master_ekis, @new_ekis;
 }
-
-$master{'eki_index'} = \@master_ekis;