Another bug fix, added check if tmptable exists in all_count