Fixed syntax errors in main, moved template