numerous PDO fixes and lessons learned