libfoundation: More records API fixes and improvements.

Not all of the errors were previously introduced by me. :sob: