Fix some errors and missing Exception class