Julia is Overwriting output of a Function

Seems that returning a copy of solution, policies and profit solves the issue. Interesting, because it seems that this does not happen all the time.