Extract painterfactory to hold state