Fixed incorrect element references. Path costs correctly computed now.