Refactor job infrastructure