Should you be passing `doc_state`, `reg_state` etc through here?

Also, long line :-(