fixed serialization. now it uses sorted maps instead of keys and ptrs