Add set type

This PR adds sane object handling.
Why `getref`? Can you explain (in the source) why not a _real_ copy function?