Refactored the master builder's message handling loop.