Fix a few bugs with the new data interface

There were some possibilities of NULL pointer dereferencing.  Also,
changed one small function to inline.