optimize function type detection and detect returning of pointers more carefully