Add try finally clauses to be sure connection gets closed if there's a failure
Add timeout parameter
Add a few convenience functions to avoid dealing with SYNTH_A,SYNTH_B constants