Crypto cleanup

Clean up duplicated functions and unnecessary Python compatibility code.