Move a little more complexity further into the lib.