Set meta data
Use reference counting to fix multiple memory leaks