OK, I'll merge your dictionary fix now from this code review, but in the process of merging I will omit the assert issue.
Please file a separate pull request for that since it's a totally unrelated issue.