BUG Fix undefined index ID

I have had a few odd cases where a record without a set ID would throw up PHP notices. This is a slightly more robust check.