Building integrated and structured memory representations during goal-directed learning