Adding surface warping. Mostly cleanup of code.