add header option validations and support for an alternate primary key

Ready for review and merge.