Improved connection management and removed a try rescue block.