Fix taking the pointer of a temporary.
Split handling of the object into a template c++/cli class (oh noes!)

Not sure if this clutters things or clarifies, but I think it helps
by hiding the awkward ownership semantics at the "impedance mismatch"
between C++ and .NET
Move implementation out of header.