Remove some autoboxing and supress warnings about unchecked casting