Porting DocumentState from bts.