Fixed issues with deep vs shallow copying