more compact serialization; fix dtype issue