HDFS-5616: more refactoring and commenting