Pass the ownership of the map object

Shouldn't try to free the wrapper yet though as layers are still owned by
it. The wrappers leak so (re)opening a lot of maps may end up consuming
more memory than actually needed, should look into this.
Anyway, it's not script writer's responsibility to manage references.