Resolve possible resource leaks and deal with IOExceptions

These are some warning cleanups. I'd appreciate eyeballs, especially on 49cec83; I think I'm doing the right thing here, but I'm pretty green to this stuff.