Added checks of get_val's return value.