Updated to have numFeatures permeate sub-functions