Header minimize finalize

These are all Ruben's header minimization branches into one.
They have been reviewed by me, tested on Win32, Win64 and Mac by me, and on Linux by Ryan.