Implement working serialization for static and dynamic case