Fix poor autogenerated code which hid the class generic T by naming the function generic T as well. Renamed function generic to U. (Credit to jlint)
Tidy unused imports, variables, and various other kinds of redundant code.
Fix documentation (somewhat). (Credit to jlint)