Template finally works. Plus some UI cleaning