Refactored the resource serialization