BUG: Multiple bugs in how dictionaries were written out to Python