add stream interface, clean up parsing