Refactored further to prepare for checksumming