Fix bug where order of key/values was changed erradically