Add missing includes and ifdefs.