Most functions added, added templates