Generic UDF and performance improvements

See issue #56