cleanup and header reorganization to speed up compilation process