Added path reconstruction with linear memory
        and changed code to use only linear memory