Extract inner classes to top-level classes