Make cleanup_structures collect everything that can be collected.

This makes destructor guarantees a little bit nicer.
Begin implementation of managed user types.

Also some related work like identifier checking when registering and
general cleanup.
Continue implementing refcounted user-types.

Prevent user types from being accessed via the wrong method.