Fix main block detection in block visit