Fixing compilation and runtime errors.