restructured code for more consistent separation of parser and cpu