Refactor parsing and attribution of types; revise spec