Fix some gc refing and unrefing issues.