Refactored to minimize digest cycles

Fixes #2