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).