Input validation fixes

@westonruter Supersedes the earlier messy PR 

Fixes #117 
Fixes #119