Switch to unions in encoding; extends to streams