Rearranged inner classes for better readability