Avoid mutating dicts to fix #49 - holes in TS not getting filled in with zeros

Fixes #49