Embedded histories: refactor and clean up