Fixes for some generics issues