Remove unused crypto functions
Clean up code and add comments