Made deep copies of some things to prevent errors from heppening