Refactor internal representation and remove extra pass.