removing unused code and adding templates