some proper math
scripted update of code from master at 194e604 some proper math