...refactor/restructure related code to achieve the same behavior on CLI and via automated job fixes #2499