refactor and get ready for offline compressing

Yea that's smart. Just updated the diff.