I tried refactoring as you suggest, it's at https://github.com/nedbat/500lines/tree/more-self-attributes .  I'm not sure I like it, because it make more methods that are only used once, privately, and more attributes on the object that aren't really needed beyond the constructor.  But we can talk about it as an option if you like.