Added some cleanup and error checking.
Also added code that demonstrates that there aren't any write conflicts.