Per #321 use RB_GC_GUARD around rb_hash_dup.
Naively scatter RB_GC_GUARD to prevent GCC optimizing values off the stack. Sprinkle Check_Type before doing hash references to ensure they aren't nil (segfault).