Added argument checks for indexes

Attempting to use `null` as an argument will now throw an
IllegalArgumentException rather than a NullPointerException later

fixes #242