Correct smart pointer use

PLEASE READ THIS COMMIT