Bug fixing and cleanup.
  - ensure total cached connections is decremented in all cases.
  - Remove deprecated API usage