moved debug stuff out of algo