refactoring for review, https://reviews.apache.org/r/16322
updated comments;