Added connection options parameter, bug fix