rewrite decode with memcpy and replace unions with structs