Added the template and minor fixes.