Replaced old, edge and new with dynamically allocated arrays.