Changes material handling to  shared_ptr.