fixed many compilation errors/warnings