Php codesniffer fixes

I did rename some variables and functions, but only if I was (pretty) sure that I wouldn't break anything.