Fixed decryption and cleaned up code