There's a lot of instance variables here. Does it make sense to localise some of them to the contexts that use them?