DuettoBackend: Refactor some code