Improve handling of invalid values dictionary