Acid and base catalyzed formation of hydrates and hemiacetals