Add copy constructor to prevent undefined behaviour.