initial
add and integrate safenormalize
merge with glmext