Error messages now send proper error codes, and inserted nested collections assign ids to their objects