Cleanup includes

There have some tiny patches. All patches are for rearrange header file inclusions.
74f0484 is for compatibility improvement. Another are for maintainability.