Huge pull request (mainly for review)

I understand that this is a huge pull request and you most probably don't want all the changes. However, I suggest you at least review the changes concerning the security of `turnin`.

You might also be interested in having a look at the issues generated while patching (https://github.com/zakkak/turnin/issues?q=is%3Aissue+is%3Aclosed)

Kind regards