fix bugs in counting optical duplicates