Added some error checking.
Added test for missing fields.