Refactoring crypto and mgmt