Fixed a few issues with unique ptr.