Check for valid args

Avoid NPEs by checking for the correct number of arguments, and returning false when appropriate.
Merge pull request #1 from guyag/patch-1

Check for valid args