Fixed errors in upscaling