Modify main.php, modify the execution flow:
    Write to DB after all executions are finished
and fix cs