Add headers for every action and refactor the undefined template attribute fix