HDFS-5623: fix a few bugs