Small refactoring and adding comments in response to PR comments.