Extract function from apply_changes, close #50