Fixed serialization issue for primitive arrays. Needs more testing.