Updating template, adding authorisation, some refactoring