Refactor by mmagnusek comments.