A hacky (but working) implementation of instance namespaces.

Also fix memberfunction merging and some other stuff.