Properly clean up failed jobs, added a failed jobs counter