fix compile errors and add missing files