Added docstrings, moved functions around. (TUI-20)