improved resource serialization