Style fixes

Various style and code improvements. Some of them were suggested by `pylint`.