Fix ref counting bug that was causing crashes on most sites.

r? @metajack