It appears to me that 2/2 should come before 1/2 so that addition of
attachment support will build on a cleaned up codebase.
Also a part of 1/2 that teaches the get_mw_first_pages function not
to feed too many titles at once may be better done as a separate
patch that is done before addition of attachment support. There may
be other things 1/2 does that should be separated into a series of
preparatory clean-up patches, but I didn't read it very carefully.