Fixed more variables and changes encryption/decryption placement