Added auto-detection of function type