[code] rewrite code to use stdClass rather than arrays