Resolve generics parameters in a safe and uniform way

Updated previous pull request