Brushed up some error checking and lookups before trying to access records that don't exist.