More gid_type sanity checks, implemented fallback for incref if gid is locked.