Fixed connection timeout issue and added comments