added connection pool listener and lots of minor bug fixing.