Separate allow_gc flag for scan

This add a separately configurable flag to enable/disable allow_gc
No, this is an ugly hack to try to get the allow_gc value of the surrounding function (as the comment says).