Som bugs caught with the help of pylint

This is a sequence of mostly trivial bugfixes on top of current next branch I caught with the help of pylint.