Fix CS errors and use correct exceptions