Fix some generics warnings, add javadoc