Apply some important fixes again for Hive 0.11

In particular, the lock contention fix has serious performance implications (~2x for the large query in the big data benchmark).