Added templates and some small fixes.