Data validation

Fixes #24, Fixes #21, Fixes #19, Fixes #18