Fix ensure_registry/0
Use raw file handles
Use new Base functions