Add primitive error handling for unexpected input
Add some checks - not that tidy
Simplify check_data