Improve comments and better handling of entity write exceptions.