WIP: Refactor crypto

Crypto refactor.... still in progress.