Fixing buildmaster leaks round 2
Created by: scarrazza
Fixes leaks in buildmaster due to the raw pointer vector allocation. This PR replaces the vector of raw pointers with smart pointers on top of #1300. @enocera could you please confirm that asan does not raise issues for you?