fix makefiles and some compile errors