Refactored some of the smart pointer implementation