fix daemon.py: use local variables in __main__ code
fix some pep8 and pylint warnings