Fix compilation errors, optimise imports.