Fixed some bugs in crypto code.