Refactored build process monitoring to prevent race conditions