Make this somewhat more general.