Switched to agent template, plus some additional changes