Added minor bugfixes.

Better parameter validation.