Fixed most compiling errors