Reduce code duplication and add code to evaluate SetValue.