Revert "Revert "Revised residual variation""

This reverts commit f7d683bbd8a6092ea2bebe2fef0d4809656eada3.