Fix bugs + change template