main: flake8: removed dead code, moved functions, renamed vars, long lines