Fix some memory leaks & valgrind warnings

Thanks to Sergio Baldovi for pointing out the valgrind warnings.
Remaining memory leaks are all in the bowels of SDL, and I'm not about to
 try to track them down.