Added separate SQL connection for large data management, and changed mechanism for testing if connection is valid.