Added a pass to move functions to an appropriate existing class if possible