HDFS-2856: several bug fixes