Refactor change detection

WIP