Several improvements

I've made a few improvements to make the code more readable, pythonic, portable, and among other things I've added support for KDE 'kdesu' command and fixed several bugs.

Please see my commit messages for further details.

I haven't generated a new binary in the repository for Linux after the changes as I don't know exactly how you generated the binary in the first place.