Fix memory issue when serializing observations #117