Add optimization to the digest cycle, handle some edge cases