Spent a lot of time debugging. Among other things, gif.h didn't want to work for some reason. Also, it took me way too long to figure out the second part.