Code clean up. Mostly moving lambda code out to named methods.