fix many compilation errors, but still linking error, wtf...