Cleaned up try/catch/finally blocks and connection closing