Adding resource closure blocks (These would be much nicer in Java 7) and
slight code cleanups.