fix some runtime errors