Encapsulate state inside a case class.