Separate rendering code into a separate file, improve docstrings