fixed bug with interpolation and clamping. still not totally sure its correct.