Added templates

And other minor changes.