Refactor and document based on code review