Fix refptr-related crashing