Move the build tooltip code into separate functions + minor cleanup.