Fixing several runtime errors.