Bug fix when dimension reduction is used.