Add more efficient build checking in wait_for_build