fixed many compilation errors