Added more checking of arguments.