Added more validation of argument types.