Fix couple of bugs related to __isset method.

1. The relationships method does not exist when there aren't any relationships defined. So be a bit more cautious before calling the function.
2. Be more cautious before saying a $key exists. Added the extra check so empty() works correctly.