Check for valid args

Avoid NPEs by checking for the correct number of arguments, and returning false when appropriate.