Fix ref counting crash