Support template instead of inline HTML. Bug fixes