HIVE-2160. Miscellaneous code improvements in the metastore,hwi and ql packages. Contributed by Chinna Rao Lalam