Code refactor and more comments.