HDFS-5615: code review feedback, refactor