Bugfix that caused crashed when downsampling.