Merging David's bugfixing and sentinel implementation