Improved JSON serialization