Tidied up decryption routine.