Fixed more warnings and added custom enchantments support.

The new try with resource statement is quite useful: (http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html).