Adds support for passing flags to New()

It also has a minor fix to report magic cookie allocation errors.
IMHO, I think it could cause some confusion since invocations will not have the package namespace which is how a normal user would end up using the API. However, if you still want me to do the change I can do it.