Fix various libgc-related crashes

This series of commits mostly fixes a couple of classes of crash caused by the use of libgc.