Major rewrite in preparation for public release.