Add missing includes and forward declarations so that headers don't depend on
other headers included before them.