(Leon/Gerrit) refactoring, idiomatic py style