Fix GMP serialization

Also fix same issue in PDO.