correctly handle inner classes removal