refactored to case classes with a factory and added argonaut encoding.