Optimize parsing by creating a collection of top level objects to reduce
the main loop size and number of checks.