Moved template stuff to separate module.