gap: fix resolving loops