Made more usage of shared pointers