added additional sanity checks and a global extract function which all
other extracts feed into