Minor fixes around function replacement, a couple of math funcs
GLSL 3.0 fix
More replace function work