fix bugs and add PCH support