make error__ extern and all global state static in main