General refactor and comment.