Implement 'dirty bit' logic

Also do some other changes important for this---see the commit messages for the first two commits
Not a huge deal, but typo on exception in docstring