Improve validation on keys