Fixed segafult while stream is referenced by persistent resource (like dba)