Switched to try-with-resources in a few places (for #83).