Work some generics-fu to remove casts from user code.