Move deepCopy to lang

Also clean up some of the code a bit