Added unique_ptr typedef
Metadata factory methods now return unique_ptr
Use unique_ptr where appropriate