replace most pointers with shared pointers