Work a bit harder to avoid unicode errors when .dumping
Correct the direction of value conversion when converting to flags