Removing unnecessary code and fixing more issues with templates