Refactoring crypto and APIs