Fix generics and clean up warnings