Fix a few runtime errors