Some refactor and more comments.