Reimplement function handling again

Functions are no longer in SMTExpr, but are seperate data types which are instances of SMTFunction.