Wrote better deep copy based on some SO answers.