Fixed runtime error in ToDictionary().
Merge commit '5a11a1e542f7ef8d6f961eeaaa6e345b519536ce'