Put in a validity check and some useful return values
Merge branch 'master' into new_record