Fixed runtime errors with api