Extend the index parameter checking from sk_value to sk_set(). Also tidy up