Update clipping functions to give best results. Also updating the variance replacement code