Improved hydration algorithm; fixes #358.