Reduce serialization overhead by ~40% by using 8/16/32 bit ints as needed

Also, fix a bug in deserializing the animation repeat sequence.