Done with debugging. Script didn't work because of low limit on open files on the bot. This reverts commit 220293da.