Tweaked additional UDFs to improve performance.