Bugfix: fixed infinite loop in index producer

also some other bugs