extra: fix some type bugs handling loops