Function changed to class. Added readfromstring

Theres still a bug with multiple avg functions in a same function tree.