Refactor + repair main task