Added deep copy method
Simpified and merged some code
Improved readability