Optimization for empty tuplets search
Fix removeTupletIfEmpty function + add more checks