Fix documentation, fix code so that it works, add new template functionality.