Correctly resolve generic return types