Fixing NPE caused by repetitive connection removal. Private methods don't need to be declared final. Using diamond operator. Removing unnecessary ArrayList operations.