Refactor parsing of structure fields and local/global top-level handling.