Changed file names, added header to template, more internal logic