Some of it's hidden behind functions, but it's the ugliest math, like...  *= delta+(1-1*delta) AUGH.