Cleanup of smart pointer logic.

Signed-off-by: Frank Mertens <frank@cyblogic.de>