Fix bugs John found

Better parameter handling