A refactor and more comments