fix errors and compile