Big crypto change, and refactoring. Please read changes.