Cleaned up some more bugs related to incorrect referencing.
Verified that the code works for multiple sizes of graphs.
Fixes #1