Handle missing end Bates value.

And some minor code layout changes and comments