Fixed serialization bugs, implemented entity serializer.