Fixed many compile errors