Doesn't much of this method duplicate code in the backend? I feel like it would be better to make the decoding more general (gawd I hate that huge case statement I wrote).