This commit adds input validation and fixes bugs with parameter parsing

Fixes #1
Fixes #2