Bug fixes and API improvements.  Also, includes the beginnings of dirty detection.