Make name_to_value and value_to_name inline

Also cleaned some indentation up and allowed the exception code to be
overriden.