Break out inner classes, format code, add generics.