Implemented workaround for shared variable mutation issue.