FIX: fixed resource leak - streams were not being closed on exception
FIX: Java conventions compliance