Setup production and testing connection handling. Added logging