More code cleanup plus options for pg connect