Fixed memory access adjustment and program now outputs the final program