Refactor rendering and add documentation.