This function probably shouldn't exit at all. Throw a runtimeexception instead?