tidy overly complex code
Split from #1860. Pylint: * R0902 too-many-instance-attributes * R0903 too-few-public-methods * R0904 too-many-public-methods * R0911 too-many-return-statements * R0912 too-many-branches * R0913 too-many-arguments * R0914 too-many-locals * R0915 too-many-statements * R1702 too-many-nested-blocks Pylint complains a lot about code being too complex. In a lot of cases, I think it’s right and refactoring is warranted. This requires a lot of detailed analysis and this issue itself might best be split.
issue