adding key object, and improving error messages.