Refactor and documentation.