Fix template parser, refactor and add docstrings.
Add documentation